Package org.opendaylight.yangtools.util
Class ImmutableOffsetMapTemplate<K>
java.lang.Object
org.opendaylight.yangtools.util.ImmutableMapTemplate<K>
org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate<K>
- Type Parameters:
K
- the type of keys maintained by this template
- All Implemented Interfaces:
Immutable
Template for instantiating
ImmutableOffsetMap
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()
.-
Method Summary
Modifier and TypeMethodDescriptionfinal <T,
V> @NonNull ImmutableOffsetMap<K, V> instantiateTransformed
(Map<K, T> fromMap, BiFunction<K, T, V> valueTransformer) Instantiate an immutable map by applying specifiedtransformer
to values offromMap
.final <V> @NonNull ImmutableOffsetMap<K,
V> instantiateWithValues
(V... values) Instantiate an immutable map by filling values from provided array.keySet()
Returns the set of keys expected by this template, in the iteration order Maps resulting from instantiation will have.static <K> @NonNull ImmutableOffsetMapTemplate<K>
ordered
(Collection<K> keys) Create a template which produces Maps with specified keys, with iteration order matching the iteration order ofkeys
.final String
toString()
static <K> @NonNull ImmutableOffsetMapTemplate<K>
unordered
(Collection<K> keys) Create a template which produces Maps with specified keys, with unconstrained iteration order.
-
Method Details
-
ordered
Create a template which produces Maps with specified keys, with iteration order matching the iteration order ofkeys
.keySet()
will return these keys in exactly the same order. The resulting map will retain insertion order throughUnmodifiableMapPhase.toModifiableMap()
transformations.- Type Parameters:
K
- the type of keys maintained by resulting template- Parameters:
keys
- Keys in requested iteration order.- Returns:
- A template object.
- Throws:
NullPointerException
- ifkeys
or any of its elements is nullIllegalArgumentException
- ifkeys
is does not have at least two keys
-
unordered
Create a template which produces Maps with specified keys, with unconstrained iteration order. Produced maps will have the iteration order matching the order returned bykeySet()
. The resulting map will NOT retain ordering throughUnmodifiableMapPhase.toModifiableMap()
transformations.- Type Parameters:
K
- the type of keys maintained by resulting template- Parameters:
keys
- Keys in any iteration order.- Returns:
- A template object.
- Throws:
NullPointerException
- ifkeys
or any of its elements is nullIllegalArgumentException
- ifkeys
is does not have at least two keys
-
keySet
Description copied from class:ImmutableMapTemplate
Returns the set of keys expected by this template, in the iteration order Maps resulting from instantiation will have.- Specified by:
keySet
in classImmutableMapTemplate<K>
- Returns:
- This template's key set
- See Also:
-
instantiateTransformed
public final <T,V> @NonNull ImmutableOffsetMap<K,V> instantiateTransformed(Map<K, T> fromMap, BiFunction<K, T, V> valueTransformer) Description copied from class:ImmutableMapTemplate
Instantiate an immutable map by applying specifiedtransformer
to values offromMap
.- Specified by:
instantiateTransformed
in classImmutableMapTemplate<K>
- Type Parameters:
T
- the type of input valuesV
- the type of mapped values- Parameters:
fromMap
- Input mapvalueTransformer
- Transformation to apply to values- Returns:
- An immutable map
-
instantiateWithValues
Description copied from class:ImmutableMapTemplate
Instantiate an immutable map by filling values from provided array. The array MUST be ordered to match key order as returned byImmutableMapTemplate.keySet()
.- Specified by:
instantiateWithValues
in classImmutableMapTemplate<K>
- Type Parameters:
V
- the type of mapped values- Parameters:
values
- Values to use- Returns:
- An immutable map
-
toString
-