Class JdkMapAdapterStringMap
- All Implemented Interfaces:
Serializable
,ReadOnlyStringMap
,StringMap
StringMap
view of a Map<String, String>
.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private boolean
private static final Comparator<? super String>
private static final long
private String[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
clear()
Removes all key-value pairs from this collection.boolean
containsKey
(String key) Returnstrue
if this data structure contains the specified key,false
otherwise.boolean
Indicates whether some other object is "equal to" this one.<V> void
forEach
(BiConsumer<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<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 String[]
<V> V
Returns the value for the specified key, ornull
if the specified key does not exist in this collection.int
hashCode()
Returns a hash code value for the object.boolean
isEmpty()
Returnstrue
if this collection is empty (size is zero),false
otherwise.boolean
isFrozen()
void
putAll
(ReadOnlyStringMap source) Copies all key-value pairs from the specifiedReadOnlyStringMap
into thisStringMap
.void
Puts the specified key-value pair into the collection.void
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.toMap()
Returns a non-null
mutableMap<String, String>
containing a snapshot of this data structure.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FROZEN
- See Also:
-
NULL_FIRST_COMPARATOR
-
map
-
immutable
private boolean immutable -
sortedKeys
-
PUT_ALL
-
-
Constructor Details
-
JdkMapAdapterStringMap
public JdkMapAdapterStringMap() -
JdkMapAdapterStringMap
-
-
Method Details
-
toMap
Description copied from interface:ReadOnlyStringMap
Returns a non-null
mutableMap<String, String>
containing a snapshot of this data structure.- Specified by:
toMap
in interfaceReadOnlyStringMap
- Returns:
- a mutable copy of this data structure in
Map<String, String>
form.
-
assertNotFrozen
private void assertNotFrozen() -
containsKey
Description copied from interface:ReadOnlyStringMap
Returnstrue
if this data structure contains the specified key,false
otherwise.- Specified by:
containsKey
in interfaceReadOnlyStringMap
- Parameters:
key
- the key whose presence to check. May benull
.- Returns:
true
if this data structure contains the specified key,false
otherwise.
-
forEach
Description copied from interface:ReadOnlyStringMap
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.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
'sBiConsumer.accept(Object, Object)
accept} method may cause aConcurrentModificationException
to be thrown.- Specified by:
forEach
in interfaceReadOnlyStringMap
- Type Parameters:
V
- type of the value.- Parameters:
action
- The action to be performed for each key-value pair in this collection.
-
forEach
Description copied from interface:ReadOnlyStringMap
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.The 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
'saccept
method may cause aConcurrentModificationException
to be thrown.- Specified by:
forEach
in interfaceReadOnlyStringMap
- Type Parameters:
V
- type of the value.S
- type of the third parameter.- Parameters:
action
- The action to be performed for each key-value pair in this collection.state
- the object to be passed as the third parameter to each invocation on the specified triconsumer.
-
getSortedKeys
-
getValue
Description copied from interface:ReadOnlyStringMap
Returns the value for the specified key, ornull
if the specified key does not exist in this collection.- Specified by:
getValue
in interfaceReadOnlyStringMap
- Parameters:
key
- the key whose value to return.- Returns:
- the value for the specified key or
null
.
-
isEmpty
public boolean isEmpty()Description copied from interface:ReadOnlyStringMap
Returnstrue
if this collection is empty (size is zero),false
otherwise.- Specified by:
isEmpty
in interfaceReadOnlyStringMap
- Returns:
true
if this collection is empty (size is zero).
-
size
public int size()Description copied from interface:ReadOnlyStringMap
Returns the number of key-value pairs in this collection.- Specified by:
size
in interfaceReadOnlyStringMap
- Returns:
- the number of key-value pairs in this collection.
-
clear
public void clear()Description copied from interface:StringMap
Removes all key-value pairs from this collection. -
freeze
public void freeze()Description copied from interface:StringMap
Makes this collection immutable. Attempts to modify the collection after thefreeze()
method was called will result in anUnsupportedOperationException
being thrown. -
isFrozen
public boolean isFrozen()Description copied from interface:StringMap
-
putAll
Description copied from interface:StringMap
Copies all key-value pairs from the specifiedReadOnlyStringMap
into thisStringMap
. -
putValue
Description copied from interface:StringMap
Puts the specified key-value pair into the collection. -
remove
Description copied from interface:StringMap
Removes the key-value pair for the specified key from this data structure. -
toString
-
equals
Description copied from interface:StringMap
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode()Description copied from interface:StringMap
Returns a hash code value for the object.
-