K
- Class of the key for the map. V
- Class of the value for the map. All Implemented Interfaces: Map<K,V>
public final class ImmutableMap<K,V> extends Object implements Map<K,V> An immutable map that could be built by convenient constructors.Example of using map Builder:
{ @code Map<String, AttibuteValue> item = new ImmutableMap.Builder<String, AttibuteValue>() .put("one", new AttibuteValue("1")) .put("two", new AttibuteValue("2")) .put("three", new AttibuteValue("3")).build(); }For small immutable maps (up to five entries), the
ImmutableMapParamter.of()
methods are preferred: Map<String, AttibuteValue> item = ImmutableMap .of("one", new AttributeValue("1"), "two", new AttributeValue("2"), "three", new AttributeValue("3"),
Nested Class Summary
Nested Classes
static class
A convenient builder for creating ImmutableMap instances.
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods
Returns a new MapParameterBuilder instance.
void
Unsupported methods
boolean
Inherited methods
boolean
boolean
int
boolean
of(K k0, V v0)
Returns an ImmutableMap instance containing a single entry.
of(K k0, V v0, K k1, V v1)
Returns an ImmutableMap instance containing two entries.
of(K k0, V v0, K k1, V v1, K k2, V v2)
Returns an ImmutableMap instance containing three entries.
of(K k0, V v0, K k1, V v1, K k2, V v2, K k3, V v3)
Returns an ImmutableMap instance containing four entries.
of(K k0, V v0, K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
Returns an ImmutableMap instance containing five entries.
void
int
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
Method Details
builder
Returns a new MapParameterBuilder instance.
of
Returns an ImmutableMap instance containing a single entry.
Parameters:k0
- Key of the single entry.v0
- Value of the single entry.of
public static <K, V> ImmutableMap<K,V> of(K k0, V v0, K k1, V v1)Returns an ImmutableMap instance containing two entries.
Parameters:k0
- Key of the first entry.v0
- Value of the first entry.k1
- Key of the second entry.v1
- Value of the second entry.of
public static <K, V> ImmutableMap<K,V> of(K k0, V v0, K k1, V v1, K k2, V v2)Returns an ImmutableMap instance containing three entries.
Parameters:k0
- Key of the first entry.v0
- Value of the first entry.k1
- Key of the second entry.v1
- Value of the second entry.k2
- Key of the third entry.v2
- Value of the third entry.of
public static <K, V> ImmutableMap<K,V> of(K k0, V v0, K k1, V v1, K k2, V v2, K k3, V v3)Returns an ImmutableMap instance containing four entries.
Parameters:k0
- Key of the first entry.v0
- Value of the first entry.k1
- Key of the second entry.v1
- Value of the second entry.k2
- Key of the third entry.v2
- Value of the third entry.k3
- Key of the fourth entry.v3
- Value of the fourth entry.of
public static <K, V> ImmutableMap<K,V> of(K k0, V v0, K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)Returns an ImmutableMap instance containing five entries.
Parameters:k0
- Key of the first entry.v0
- Value of the first entry.k1
- Key of the second entry.v1
- Value of the second entry.k2
- Key of the third entry.v2
- Value of the third entry.k3
- Key of the fourth entry.v3
- Value of the fourth entry.k4
- Key of the fifth entry.v4
- Value of the fifth entry.containsKey
public boolean containsKey(Object key)Inherited methods
Specified by:containsKey
in interfaceMap<K,V>
containsValue
public boolean containsValue(Object value) Specified by:containsValue
in interfaceMap<K,V>
entrySet
Specified by:entrySet
in interfaceMap<K,V>
get
Specified by:get
in interfaceMap<K,V>
isEmpty
public boolean isEmpty()
Specified by:isEmpty
in interfaceMap<K,V>
keySet
public Set<K> keySet() Specified by:keySet
in interfaceMap<K,V>
size
public int size()
Specified by:size
in interfaceMap<K,V>
values
Specified by:values
in interfaceMap<K,V>
clear
public void clear()
Unsupported methods
Specified by:clear
in interfaceMap<K,V>
put
public V put(K key, V value) Specified by:put
in interfaceMap<K,V>
putAll
public void putAll(Map<? extends K,? extends V> map) Specified by:putAll
in interfaceMap<K,V>
remove
Specified by:remove
in interfaceMap<K,V>
equals
public boolean equals(Object o) Specified by:equals
in interfaceMap<K,V>
Overrides:equals
in classObject
hashCode
public int hashCode()
Specified by:hashCode
in interfaceMap<K,V>
Overrides:hashCode
in classObject
toString
Overrides:toString
in classObject
ncG1vNJzZmirlKB7ornAs6anmaeoe6S7zGihmq6RZK6xtY6lmK2do6l8tLvFra6aqpVkrq6t2ailaJmnqMClt46uq6Kko2SWrrnUrZibpJWCrrF6x62kpQ%3D%3D