Package org.opendaylight.yangtools.util
Class SharedSingletonMapTemplate<K>
- java.lang.Object
-
- org.opendaylight.yangtools.util.ImmutableMapTemplate<K>
-
- org.opendaylight.yangtools.util.SharedSingletonMapTemplate<K>
-
- Type Parameters:
K
- the type of keys maintained by this template
- All Implemented Interfaces:
Immutable
,MutationBehaviour<Immutable>
public abstract class SharedSingletonMapTemplate<K> extends ImmutableMapTemplate<K>
Template for instantiatingSharedSingletonMap
instances with a fixed key. The template can then be used as a factory for instances via usinginstantiateTransformed(Map, BiFunction)
or, more efficiently, usinginstantiateWithValue(Object)
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T,V>
@NonNull SharedSingletonMap<K,V>instantiateTransformed(Map<K,T> fromMap, BiFunction<K,T,V> valueTransformer)
Instantiate an immutable map by applying specifiedtransformer
to values offromMap
.abstract <V> @NonNull SharedSingletonMap<K,V>
instantiateWithValue(V value)
Instantiate an immutable map with the value supplied.<V> @NonNull SharedSingletonMap<K,V>
instantiateWithValues(V... values)
Instantiate an immutable map by filling values from provided array.SingletonSet<K>
keySet()
Returns the set of keys expected by this template, in the iteration order Maps resulting from instantiation will have.static <K> @NonNull SharedSingletonMapTemplate<K>
ordered(K key)
Create a template which produces Maps with specified key.String
toString()
static <K> @NonNull SharedSingletonMapTemplate<K>
unordered(K key)
Create a template which produces Maps with specified key.-
Methods inherited from class org.opendaylight.yangtools.util.ImmutableMapTemplate
ordered, unordered
-
-
-
-
Method Detail
-
ordered
public static <K> @NonNull SharedSingletonMapTemplate<K> ordered(K key)
Create a template which produces Maps with specified key. The resulting map will retain insertion order throughUnmodifiableMapPhase.toModifiableMap()
transformations.- Type Parameters:
K
- the type of keys maintained by resulting template- Parameters:
key
- Single key in resulting map- Returns:
- A template object.
- Throws:
NullPointerException
- ifkey
is null
-
unordered
public static <K> @NonNull SharedSingletonMapTemplate<K> unordered(K key)
Create a template which produces Maps with specified key. The resulting map will NOT retain ordering throughUnmodifiableMapPhase.toModifiableMap()
transformations.- Type Parameters:
K
- the type of keys maintained by resulting template- Parameters:
key
- Single key in resulting map- Returns:
- A template object.
- Throws:
NullPointerException
- ifkey
is null
-
keySet
public final SingletonSet<K> 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:
Map.keySet()
-
instantiateTransformed
public final <T,V> @NonNull SharedSingletonMap<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
@SafeVarargs public final <V> @NonNull SharedSingletonMap<K,V> instantiateWithValues(V... values)
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
-
instantiateWithValue
public abstract <V> @NonNull SharedSingletonMap<K,V> instantiateWithValue(V value)
Instantiate an immutable map with the value supplied.- Type Parameters:
V
- the type of mapped values- Parameters:
value
- Value to use- Returns:
- An immutable map
- Throws:
NullPointerException
- ifvalue
is null
-
-