@ConsumerType public interface ValueMap extends java.util.Map<java.lang.String,java.lang.Object>
ValueMap
is an easy way to access properties of a resource.
With resources you can use Resource.getValueMap()
to obtain the
value map of a resource. The various getter methods can be used to get the
properties of the resource.
In addition a value map returned by a resource supports getting of deep
values, like get("content/title") which is equivalent to call
getChild("content") on the resource, get the value map of that resource
and call get("title") - but without requiring to do all the checks.
Only the following methods support deep reads: Map.get(Object)
,
get(String, Class)
, get(String, Object)
and
Map.containsKey(Object)
.
A ValueMap
should be immutable.
Modifier and Type | Field and Description |
---|---|
static ValueMap |
EMPTY
Empty immutable value map.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
get(@NotNull java.lang.String name,
@NotNull java.lang.Class<T> type)
Get a named property and convert it into the given type.
|
<T> T |
get(@NotNull java.lang.String name,
T defaultValue)
Get a named property and convert it into the given type.
|
static final ValueMap EMPTY
@Nullable <T> T get(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.Class<T> type)
null
in this
case.T
- The class of the typename
- The name of the propertytype
- The class of the typenull
if
non existing or can't be converted.@NotNull <T> T get(@NotNull @NotNull java.lang.String name, @NotNull T defaultValue)
null
.
Therefore all implementations should internally call Map.get(Object)
when the 2nd parameter
has value null
.T
- The expected typename
- The name of the propertydefaultValue
- The default value to use if the named property does
not exist or cannot be converted to the requested type. The
default value is also used to define the type to convert the
value to. Must not be null
. If you want to return null
by default
rather rely on get(String, Class)
.Copyright © 2010 - 2020 Adobe. All Rights Reserved