public class JdkMapAdapterStringMap extends Object implements StringMap
StringMap
view of a Map<String, String>
.Constructor and Description |
---|
JdkMapAdapterStringMap() |
JdkMapAdapterStringMap(Map<String,String> map) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all key-value pairs from this collection.
|
boolean |
containsKey(String key)
Returns
true if this data structure contains the specified key, false otherwise. |
boolean |
equals(Object object)
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.
|
<V> V |
getValue(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)
Copies all key-value pairs from the specified
ReadOnlyStringMap into this StringMap . |
void |
putValue(String key,
Object value)
Puts the specified key-value pair into the collection.
|
void |
remove(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.
|
Map<String,String> |
toMap()
Returns a non-
null mutable Map<String, String> containing a snapshot of this data structure. |
String |
toString() |
public Map<String,String> toMap()
ReadOnlyStringMap
null
mutable Map<String, String>
containing a snapshot of this data structure.toMap
in interface ReadOnlyStringMap
Map<String, String>
form.public boolean containsKey(String key)
ReadOnlyStringMap
true
if this data structure contains the specified key, false
otherwise.containsKey
in interface ReadOnlyStringMap
key
- the key whose presence to check. May be null
.true
if this data structure contains the specified key, false
otherwise.public <V> void forEach(BiConsumer<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 ReadOnlyStringMap
V
- type of the value.action
- The action to be performed for each key-value pair in this collection.public <V,S> void forEach(TriConsumer<String,? super V,S> action, S state)
ReadOnlyStringMap
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
's accept
method may cause a
ConcurrentModificationException
to be thrown.
forEach
in interface ReadOnlyStringMap
V
- type of the value.S
- type of the third parameter.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.public <V> V getValue(String key)
ReadOnlyStringMap
null
if the specified key does not exist in this collection.getValue
in interface ReadOnlyStringMap
key
- the key whose value to return.null
.public boolean isEmpty()
ReadOnlyStringMap
true
if this collection is empty (size is zero), false
otherwise.isEmpty
in interface ReadOnlyStringMap
true
if this collection is empty (size is zero).public int size()
ReadOnlyStringMap
size
in interface ReadOnlyStringMap
public void clear()
StringMap
public void freeze()
StringMap
freeze()
method was called
will result in an UnsupportedOperationException
being thrown.public boolean isFrozen()
StringMap
public void putAll(ReadOnlyStringMap source)
StringMap
ReadOnlyStringMap
into this StringMap
.public void putValue(String key, Object value)
StringMap
public void remove(String key)
StringMap
public boolean equals(Object object)
StringMap
equals
in interface StringMap
equals
in class Object
object
- the reference object with which to compare.true
if this object is the same as the obj argument; false
otherwise.StringMap.hashCode()
Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.