public final class Mappings
extends java.lang.Object
Mapping.| Modifier and Type | Method and Description |
|---|---|
static <K,V> Mapping<K,V> |
augment(Mapping<K,V> in,
java.lang.Object... keysAndValues)
Equivalent with
union(Mapping, Mapping), where the first argument is in and the second is
constructed from the given keyValuePairs. |
static <K,V> Mapping<K,V> |
constant(V constantValue) |
static <K,V> Mapping<K,V> |
fromMap(java.util.Map<K,V> map)
Returns a proxy
Mapping for a Map. |
static <K,T> T |
get(Mapping<? extends K,?> mapping,
java.lang.Object key,
java.lang.Class<T> targetType)
Invokes
Mapping.get(Object) on the mapping and, if the result is not null, converts it
to the given targetType. |
static <K> java.lang.Object |
getNonNull(Mapping<K,?> mapping,
java.lang.String key) |
static <K,T> T |
getNonNull(Mapping<K,?> mapping,
java.lang.String key,
java.lang.Class<T> targetType) |
static <K,V> Mapping<K,V> |
mapping(java.lang.Object... keysAndValues) |
static <K,V> Mapping<K,V> |
none() |
static <K,V> Mapping<K,V> |
override(Mapping<K,V> in,
java.lang.Object... keysAndValues)
Equivalent with
union(Mapping, Mapping), where the first argument is constructed from the given keyValuePairs and the second argument is in. |
static Mapping<java.lang.String,java.lang.Object> |
propertiesOf(java.lang.Object subject)
Returns a mapping of property names to property values for the given
subject object. |
static <K,V> Mapping<K,V> |
union(Mapping<K,V> op1,
Mapping<K,V> op2)
Returns a mapping that implements the "union" of two mappings.
|
public static <K,V> Mapping<K,V> fromMap(java.util.Map<K,V> map)
public static <K,V> Mapping<K,V> mapping(java.lang.Object... keysAndValues)
keysAndValues - An alternating sequence of keys and values; even elements must have type K, odd
elements must have type Vpublic static Mapping<java.lang.String,java.lang.Object> propertiesOf(java.lang.Object subject)
subject object.
The existence of a property "propertyName" is determined by the existence of one of the
following, in this order:
getPropertyName()"
isPropertyName()"
hasPropertyName()"
propertyName()"
propertyName"
@Nullable public static <K,T> T get(Mapping<? extends K,?> mapping, java.lang.Object key, java.lang.Class<T> targetType)
Mapping.get(Object) on the mapping and, if the result is not null, converts it
to the given targetType.java.lang.IllegalArgumentException - The type of the value of the property is not assignable to Tpublic static <K> java.lang.Object getNonNull(Mapping<K,?> mapping, java.lang.String key)
mapping maps the keyjava.lang.IllegalArgumentException - The mapping does not contain the given keyjava.lang.IllegalArgumentException - The mapping contains the key, but the mapped value is nullpublic static <K,T> T getNonNull(Mapping<K,?> mapping, java.lang.String key, java.lang.Class<T> targetType)
mapping maps the keyjava.lang.IllegalArgumentException - The mapping does not contain the given keyjava.lang.IllegalArgumentException - The mapping contains the key, but the mapped value is nulljava.lang.IllegalArgumentException - The mapping contains the key, but the mapped value is not
assignable to Tpublic static <K,V> Mapping<K,V> union(Mapping<K,V> op1, Mapping<K,V> op2)
For the returned Mapping, the following conditions apply:
null iff none of the operands contain the key.
public static <K,V> Mapping<K,V> augment(Mapping<K,V> in, java.lang.Object... keysAndValues)
union(Mapping, Mapping), where the first argument is in and the second is
constructed from the given keyValuePairs.keysAndValues - An alternating sequence of keys and values; even elements must have type K, odd
elements must have type Vpublic static <K,V> Mapping<K,V> override(Mapping<K,V> in, java.lang.Object... keysAndValues)
union(Mapping, Mapping), where the first argument is constructed from the given keyValuePairs and the second argument is in.keysAndValues - An alternating sequence of keys and values; even elements must have type K, odd
elements must have type Vpublic static <K,V> Mapping<K,V> constant(V constantValue)