public final class ValueMap extends Object
Manages a collection of named values as persisted in a work object.
Modifier and Type | Class and Description |
---|---|
static class |
ValueMap.Builder
Builder for a
ValueMap instance. |
Modifier and Type | Method and Description |
---|---|
static ValueMap.Builder |
builder()
Creates a builder for a new value map instance.
|
static ValueMap.Builder |
builder(ValueMap template)
Creates a builder for a new value map instance from the given template map.
|
ValueMap |
filter(Predicate<Map.Entry<String,Object>> predicate)
Filers values in the instance based on the input predicate
|
<T> T |
getValue(String name,
Class<T> requiredType)
Returns the value with the given name, cast to the expected type.
|
<V> V |
getValue(ValueAccessor<V> valueAccessor)
Returns the de-serialized value referenced by the given value accessor.
|
static ValueMap |
of()
Creates an empty value map.
|
static ValueMap |
of(Map<String,Object> values)
Creates a value map from the given serialized values.
|
static ValueMap |
of(String name,
Object value)
Creates a new value map from the given name/value pair.
|
static ValueMap |
of(String name1,
Object value1,
String name2,
Object value2)
Creates a new value map from the given name/value pairs.
|
static ValueMap |
of(String name1,
Object value1,
String name2,
Object value2,
String name3,
Object value3)
Creates a new value map from the given name/value pairs.
|
static <V> ValueMap |
of(ValueAccessor<V> valueAccessor,
V value)
Creates a new value map from the given name/value pair.
|
static <V1,V2> ValueMap |
of(ValueAccessor<V1> accessor1,
V1 value1,
ValueAccessor<V2> accessor2,
V2 value2)
Creates a new value map from the given name/value pairs.
|
static <V1,V2,V3> ValueMap |
of(ValueAccessor<V1> accessor1,
V1 value1,
ValueAccessor<V2> accessor2,
V2 value2,
ValueAccessor<V3> accessor3,
V3 value3)
Creates a new value map from the given name/value pairs.
|
Map<String,Object> |
toMap()
Returns the serialized value data represented as a plain map with key/value pairs.
|
public Map<String,Object> toMap()
Returns the serialized value data represented as a plain map with key/value pairs.
public <V> V getValue(ValueAccessor<V> valueAccessor)
Returns the de-serialized value referenced by the given value accessor.
V
- the value typevalueAccessor
- the value accessorpublic <T> T getValue(String name, Class<T> requiredType)
Returns the value with the given name, cast to the expected type.
Only values from this work object will be considered. Values inherited from parent work objects are ignored.
T
- the required typename
- the name of the value whose value to returnrequiredType
- the required class of the value valueIllegalArgumentException
- if the value does not have the required typepublic static ValueMap of()
Creates an empty value map.
public static ValueMap of(Map<String,Object> values)
Creates a value map from the given serialized values.
values
- the map of serialized values to addpublic static <V> ValueMap of(ValueAccessor<V> valueAccessor, V value)
Creates a new value map from the given name/value pair.
V
- the expected transient type of the valuevalueAccessor
- the value namevalue
- the valuepublic static <V1,V2> ValueMap of(ValueAccessor<V1> accessor1, V1 value1, ValueAccessor<V2> accessor2, V2 value2)
Creates a new value map from the given name/value pairs.
V1
- the expected transient type of the first valueV2
- the expected transient type of the second valueaccessor1
- the first value namevalue1
- the first valueaccessor2
- the second value namevalue2
- the second valuepublic static <V1,V2,V3> ValueMap of(ValueAccessor<V1> accessor1, V1 value1, ValueAccessor<V2> accessor2, V2 value2, ValueAccessor<V3> accessor3, V3 value3)
Creates a new value map from the given name/value pairs.
V1
- the expected transient type of the first valueV2
- the expected transient type of the second valueV3
- the expected transient type of the third valueaccessor1
- the first value namevalue1
- the first valueaccessor2
- the second value namevalue2
- the second valueaccessor3
- the third value namevalue3
- the third valuepublic static ValueMap of(String name, Object value)
Creates a new value map from the given name/value pair.
name
- the value namevalue
- the serialized valuepublic static ValueMap of(String name1, Object value1, String name2, Object value2)
Creates a new value map from the given name/value pairs.
name1
- the first value namevalue1
- the first serialized valuename2
- the second value namevalue2
- the second serialized valuepublic static ValueMap of(String name1, Object value1, String name2, Object value2, String name3, Object value3)
Creates a new value map from the given name/value pairs.
name1
- the first value namevalue1
- the first serialized valuename2
- the second value namevalue2
- the second serialized valuename3
- the third value namevalue3
- the third serialized valuepublic static ValueMap.Builder builder()
Creates a builder for a new value map instance.
public static ValueMap.Builder builder(ValueMap template)
Creates a builder for a new value map instance from the given template map.
template
- the template value mapCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.