class JdkMapAdapterStringMap extends java.lang.Object implements StringMap
StringMap view of a Map<String, String>.| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
FROZEN |
private boolean |
immutable |
private java.util.Map<java.lang.String,java.lang.String> |
map |
private static java.util.Comparator<? super java.lang.String> |
NULL_FIRST_COMPARATOR |
private static TriConsumer<java.lang.String,java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
PUT_ALL |
private static long |
serialVersionUID |
private java.lang.String[] |
sortedKeys |
| Constructor and Description |
|---|
JdkMapAdapterStringMap() |
JdkMapAdapterStringMap(java.util.Map<java.lang.String,java.lang.String> map) |
| Modifier and Type | Method and Description |
|---|---|
private void |
assertNotFrozen() |
void |
clear()
Removes all key-value pairs from this collection.
|
boolean |
containsKey(java.lang.String key)
Returns
true if this data structure contains the specified key, false otherwise. |
boolean |
equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one.
|
<V> void |
forEach(BiConsumer<java.lang.String,? super V> action)
Performs the given action for each key-value pair in this data structure
until all entries have been processed or the action throws an exception.
|
<V,S> void |
forEach(TriConsumer<java.lang.String,? super V,S> action,
S state)
Performs the given action for each key-value pair in this data structure
until all entries have been processed or the action throws an exception.
|
void |
freeze()
Makes this collection immutable.
|
private java.lang.String[] |
getSortedKeys() |
<V> V |
getValue(java.lang.String key)
Returns the value for the specified key, or
null if the specified key does not exist in this collection. |
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isEmpty()
Returns
true if this collection is empty (size is zero), false otherwise. |
boolean |
isFrozen()
|
void |
putAll(ReadOnlyStringMap source)
Copy all key-value pairs from the specified
ReadOnlyStringMap into this StringMap. |
void |
putValue(java.lang.String key,
java.lang.Object value)
Puts the specified key-value pair into the collection.
|
void |
remove(java.lang.String key)
Removes the key-value pair for the specified key from this data structure.
|
int |
size()
Returns the number of key-value pairs in this collection.
|
java.util.Map<java.lang.String,java.lang.String> |
toMap()
Returns a non-
null mutable Map<String, String> containing a snapshot of this data structure. |
java.lang.String |
toString() |
private static final long serialVersionUID
private static final java.lang.String FROZEN
private static final java.util.Comparator<? super java.lang.String> NULL_FIRST_COMPARATOR
private final java.util.Map<java.lang.String,java.lang.String> map
private boolean immutable
private transient java.lang.String[] sortedKeys
private static TriConsumer<java.lang.String,java.lang.String,java.util.Map<java.lang.String,java.lang.String>> PUT_ALL
public JdkMapAdapterStringMap()
public JdkMapAdapterStringMap(java.util.Map<java.lang.String,java.lang.String> map)
public java.util.Map<java.lang.String,java.lang.String> toMap()
ReadOnlyStringMapnull mutable Map<String, String> containing a snapshot of this data structure.toMap in interface ReadOnlyStringMapMap<String, String> formprivate void assertNotFrozen()
public boolean containsKey(java.lang.String key)
ReadOnlyStringMaptrue if this data structure contains the specified key, false otherwise.containsKey in interface ReadOnlyStringMapkey - the key whose presence to check. May be null.true if this data structure contains the specified key, false otherwisepublic <V> void forEach(BiConsumer<java.lang.String,? super V> action)
ReadOnlyStringMap
Some implementations may not support structural modifications (adding new elements or removing elements) while
iterating over the contents. In such implementations, attempts to add or remove elements from the
BiConsumer's BiConsumer.accept(Object, Object) accept} method may cause a
ConcurrentModificationException to be thrown.
forEach in interface ReadOnlyStringMapV - type of the valueaction - The action to be performed for each key-value pair in this collectionpublic <V,S> void forEach(TriConsumer<java.lang.String,? super V,S> action, S state)
ReadOnlyStringMapThe third parameter lets callers pass in a stateful object to be modified with the key-value pairs, so the TriConsumer implementation itself can be stateless and potentially reusable.
Some implementations may not support structural modifications (adding new elements or removing elements) while
iterating over the contents. In such implementations, attempts to add or remove elements from the
TriConsumer's accept method may cause a
ConcurrentModificationException to be thrown.
forEach in interface ReadOnlyStringMapV - type of the valueS - type of the third parameteraction - The action to be performed for each key-value pair in this collectionstate - the object to be passed as the third parameter to each invocation on the specified
triconsumerprivate java.lang.String[] getSortedKeys()
public <V> V getValue(java.lang.String key)
ReadOnlyStringMapnull if the specified key does not exist in this collection.getValue in interface ReadOnlyStringMapkey - the key whose value to returnnullpublic boolean isEmpty()
ReadOnlyStringMaptrue if this collection is empty (size is zero), false otherwise.isEmpty in interface ReadOnlyStringMaptrue if this collection is empty (size is zero)public int size()
ReadOnlyStringMapsize in interface ReadOnlyStringMappublic void clear()
StringMappublic void freeze()
StringMapfreeze() method was called
will result in an UnsupportedOperationException being thrown.public boolean isFrozen()
StringMappublic void putAll(ReadOnlyStringMap source)
StringMapReadOnlyStringMap into this StringMap.public void putValue(java.lang.String key,
java.lang.Object value)
StringMappublic void remove(java.lang.String key)
StringMappublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object object)
StringMapequals in interface StringMapequals in class java.lang.Objectobject - the reference object with which to compare.true if this object is the same as the obj argument; false otherwise.StringMap.hashCode()