- Type Parameters:
K- key typeV- value type
- All Superinterfaces:
Map<K,,V> SequencedMap<K,V>
A
Map with consistent order of entries. All static factory methods
produce unmodifiable maps.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> OrderedMap <K, V> Return an OrderedMap that contains a copy of the provided Map.booleanCompares the provided object with this map for equality in accordance with the specification ofMap.equals(java.lang.Object).keys()AListcontaining the keys of this OrderedMap.static <K,V> OrderedMap <K, V> of()Returns an empty OrderedMap.static <K,V> OrderedMap <K, V> of(K k1, V v1) Returns an OrderedMap with a single mapping.static <K,V> OrderedMap <K, V> of(K k1, V v1, K k2, V v2) Returns an OrderedMap with two mappings.static <K,V> OrderedMap <K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) Returns an OrderedMap with three mappings.static <K,V> OrderedMap <K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) Returns an OrderedMap with four mappings.static <K,V> OrderedMap <K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) Returns an OrderedMap with five mappings.static <K,V> OrderedMap <K, V> Returns an OrderedMap from the given entries.OrderedMap<K, V> reversed()Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry, putFirst, putLast, sequencedEntrySet, sequencedKeySet, sequencedValues
-
Method Details
-
keys
AListcontaining the keys of this OrderedMap.Because neither Map nor Set equality depends on order, code needing to verify whether an OrderedMap contains the same mappings in the same order should also check for equality of the keys list.
This method may also be more efficient than calling
Map.keySet().- Returns:
- map keys as list
-
reversed
OrderedMap<K,V> reversed()- Specified by:
reversedin interfaceSequencedMap<K,V>
-
equals
Compares the provided object with this map for equality in accordance with the specification ofMap.equals(java.lang.Object).Because Map equality does not depends on order, code needing to verify whether an OrderedMap contains the same mappings in the same order should also check for equality of the
keys()list. -
of
Returns an empty OrderedMap.- Type Parameters:
K- key typeV- value type- Returns:
- empty map
-
of
Returns an OrderedMap with a single mapping.- Type Parameters:
K- key typeV- value type- Parameters:
k1- keyv1- value- Returns:
- an OrderedMap of the provided mapping
- Throws:
NullPointerException- if key or value are null
-
of
Returns an OrderedMap with two mappings.- Type Parameters:
K- key typeV- value type- Parameters:
k1- first keyv1- first valuek2- second keyv2- second value- Returns:
- an OrderedMap of the provided mappings
- Throws:
NullPointerException- if any keys or values are nullIllegalArgumentException- if any keys are duplicated
-
of
Returns an OrderedMap with three mappings.- Type Parameters:
K- key typeV- value type- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third value- Returns:
- an OrderedMap of the provided mappings
- Throws:
NullPointerException- if any keys or values are nullIllegalArgumentException- if any keys are duplicated
-
of
Returns an OrderedMap with four mappings.- Type Parameters:
K- key typeV- value type- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third valuek4- fourth keyv4- fourth value- Returns:
- an OrderedMap of the provided mappings
- Throws:
NullPointerException- if any keys or values are nullIllegalArgumentException- if any keys are duplicated
-
of
Returns an OrderedMap with five mappings.- Type Parameters:
K- key typeV- value type- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third valuek4- fourth keyv4- fourth valuek5- fifth keyv5- fifth value- Returns:
- an OrderedMap of the provided mappings
- Throws:
NullPointerException- if any keys or values are nullIllegalArgumentException- if any keys are duplicated
-
ofEntries
Returns an OrderedMap from the given entries. The entries themselves are not stored in the map.- Type Parameters:
K- key typeV- value type- Parameters:
entries- map entries- Returns:
- an OrderedMap of the provided mappings
- Throws:
NullPointerException- if any keys or values are null, or ifentriesis nullIllegalArgumentException- if any keys are duplicated
-
copyOf
Return an OrderedMap that contains a copy of the provided Map. The order will be the same as the iteration order of the map's entry set.If the map is already an unmodifiable OrderedMap it may be returned as is.
- Type Parameters:
K- key typeV- value type- Parameters:
map- map to copy- Returns:
- an ordered map copy of the provided map
-