K - the type of keys maintained by this template@Beta public abstract class ImmutableMapTemplate<K> extends Object implements Immutable
UnmodifiableMapPhase instances with a fixed set of keys. The template can then be
used as a factory for instances via using instantiateTransformed(Map, BiFunction) or, more efficiently,
using instantiateWithValues(Object[]) where the argument array has values ordered corresponding to the key
order defined by keySet().
If the keySet is static known to contain only a single key, consider using SharedSingletonMapTemplate. If
it is statically known to contain multiple keys, consider using ImmutableOffsetMapTemplate.
| Modifier and Type | Method and Description |
|---|---|
abstract <T,V> @NonNull UnmodifiableMapPhase<K,V> |
instantiateTransformed(Map<K,T> fromMap,
BiFunction<K,T,V> keyValueTransformer)
Instantiate an immutable map by applying specified
transformer to values of fromMap. |
abstract <V> @NonNull UnmodifiableMapPhase<K,V> |
instantiateWithValues(V... values)
Instantiate an immutable map by filling values from provided array.
|
abstract Set<K> |
keySet()
Returns the set of keys expected by this template, in the iteration order Maps resulting from instantiation
will have.
|
static <K> @NonNull ImmutableMapTemplate<K> |
ordered(Collection<K> keys)
Create a template which produces Maps with specified keys, with iteration order matching the iteration order
of
keys. |
static <K> @NonNull ImmutableMapTemplate<K> |
unordered(Collection<K> keys)
Create a template which produces Maps with specified keys, with unconstrained iteration order.
|
public static <K> @NonNull ImmutableMapTemplate<K> ordered(Collection<K> keys)
keys. keySet() will return these keys in exactly the same order. The resulting map will
retain insertion order through UnmodifiableMapPhase.toModifiableMap() transformations.K - the type of keys maintained by resulting templatekeys - Keys in requested iteration order.NullPointerException - if keys or any of its elements is nullIllegalArgumentException - if keys is emptypublic static <K> @NonNull ImmutableMapTemplate<K> unordered(Collection<K> keys)
keySet(). The resulting map will
NOT retain ordering through UnmodifiableMapPhase.toModifiableMap() transformations.K - the type of keys maintained by resulting templatekeys - Keys in any iteration order.NullPointerException - if keys or any of its elements is nullIllegalArgumentException - if keys is emptypublic abstract <T,V> @NonNull UnmodifiableMapPhase<K,V> instantiateTransformed(Map<K,T> fromMap, BiFunction<K,T,V> keyValueTransformer)
transformer to values of fromMap.T - the type of input valuesV - the type of mapped valuesfromMap - Input mapkeyValueTransformer - Transformation to apply to valuesNullPointerException - if any of the arguments is null or if the transformer produces a null valueIllegalArgumentException - if fromMap#keySet() does not match this template's keyspublic abstract <V> @NonNull UnmodifiableMapPhase<K,V> instantiateWithValues(V... values)
keySet().V - the type of mapped valuesvalues - Values to useNullPointerException - if values or any of its elements is nullIllegalArgumentException - if values.length does not match the number of keys in this templatepublic abstract Set<K> keySet()
Map.keySet()Copyright © 2019 OpenDaylight. All rights reserved.