Class JdkMapAdapterStringMap
- java.lang.Object
-
- org.apache.logging.log4j.core.impl.JdkMapAdapterStringMap
-
- All Implemented Interfaces:
java.io.Serializable,ReadOnlyStringMap,StringMap
public class JdkMapAdapterStringMap extends java.lang.Object implements StringMap
Provides a read-onlyStringMapview of aMap<String, String>.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringFROZENprivate booleanimmutableprivate java.util.Map<java.lang.String,java.lang.String>mapprivate static java.util.Comparator<? super java.lang.String>NULL_FIRST_COMPARATORprivate static TriConsumer<java.lang.String,java.lang.String,java.util.Map<java.lang.String,java.lang.String>>PUT_ALLprivate static longserialVersionUIDprivate java.lang.String[]sortedKeys
-
Constructor Summary
Constructors Constructor Description JdkMapAdapterStringMap()JdkMapAdapterStringMap(java.util.Map<java.lang.String,java.lang.String> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassertNotFrozen()voidclear()Removes all key-value pairs from this collection.booleancontainsKey(java.lang.String key)Returnstrueif this data structure contains the specified key,falseotherwise.booleanequals(java.lang.Object object)Indicates whether some other object is "equal to" this one.<V> voidforEach(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>
voidforEach(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.voidfreeze()Makes this collection immutable.private java.lang.String[]getSortedKeys()<V> VgetValue(java.lang.String key)Returns the value for the specified key, ornullif the specified key does not exist in this collection.inthashCode()Returns a hash code value for the object.booleanisEmpty()Returnstrueif this collection is empty (size is zero),falseotherwise.booleanisFrozen()voidputAll(ReadOnlyStringMap source)Copies all key-value pairs from the specifiedReadOnlyStringMapinto thisStringMap.voidputValue(java.lang.String key, java.lang.Object value)Puts the specified key-value pair into the collection.voidremove(java.lang.String key)Removes the key-value pair for the specified key from this data structure.intsize()Returns the number of key-value pairs in this collection.java.util.Map<java.lang.String,java.lang.String>toMap()Returns a non-nullmutableMap<String, String>containing a snapshot of this data structure.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
FROZEN
private static final java.lang.String FROZEN
- See Also:
- Constant Field Values
-
NULL_FIRST_COMPARATOR
private static final java.util.Comparator<? super java.lang.String> NULL_FIRST_COMPARATOR
-
map
private final java.util.Map<java.lang.String,java.lang.String> map
-
immutable
private boolean immutable
-
sortedKeys
private transient java.lang.String[] sortedKeys
-
PUT_ALL
private static TriConsumer<java.lang.String,java.lang.String,java.util.Map<java.lang.String,java.lang.String>> PUT_ALL
-
-
Method Detail
-
toMap
public java.util.Map<java.lang.String,java.lang.String> toMap()
Description copied from interface:ReadOnlyStringMapReturns a non-nullmutableMap<String, String>containing a snapshot of this data structure.- Specified by:
toMapin interfaceReadOnlyStringMap- Returns:
- a mutable copy of this data structure in
Map<String, String>form.
-
assertNotFrozen
private void assertNotFrozen()
-
containsKey
public boolean containsKey(java.lang.String key)
Description copied from interface:ReadOnlyStringMapReturnstrueif this data structure contains the specified key,falseotherwise.- Specified by:
containsKeyin interfaceReadOnlyStringMap- Parameters:
key- the key whose presence to check. May benull.- Returns:
trueif this data structure contains the specified key,falseotherwise.
-
forEach
public <V> void forEach(BiConsumer<java.lang.String,? super V> action)
Description copied from interface:ReadOnlyStringMapPerforms 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 aConcurrentModificationExceptionto be thrown.- Specified by:
forEachin interfaceReadOnlyStringMap- Type Parameters:
V- type of the value.- Parameters:
action- The action to be performed for each key-value pair in this collection.
-
forEach
public <V,S> void forEach(TriConsumer<java.lang.String,? super V,S> action, S state)
Description copied from interface:ReadOnlyStringMapPerforms 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'sacceptmethod may cause aConcurrentModificationExceptionto be thrown.- Specified by:
forEachin 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
private java.lang.String[] getSortedKeys()
-
getValue
public <V> V getValue(java.lang.String key)
Description copied from interface:ReadOnlyStringMapReturns the value for the specified key, ornullif the specified key does not exist in this collection.- Specified by:
getValuein 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:ReadOnlyStringMapReturnstrueif this collection is empty (size is zero),falseotherwise.- Specified by:
isEmptyin interfaceReadOnlyStringMap- Returns:
trueif this collection is empty (size is zero).
-
size
public int size()
Description copied from interface:ReadOnlyStringMapReturns the number of key-value pairs in this collection.- Specified by:
sizein interfaceReadOnlyStringMap- Returns:
- the number of key-value pairs in this collection.
-
clear
public void clear()
Description copied from interface:StringMapRemoves all key-value pairs from this collection.
-
freeze
public void freeze()
Description copied from interface:StringMapMakes this collection immutable. Attempts to modify the collection after thefreeze()method was called will result in anUnsupportedOperationExceptionbeing thrown.
-
isFrozen
public boolean isFrozen()
Description copied from interface:StringMap
-
putAll
public void putAll(ReadOnlyStringMap source)
Description copied from interface:StringMapCopies all key-value pairs from the specifiedReadOnlyStringMapinto thisStringMap.
-
putValue
public void putValue(java.lang.String key, java.lang.Object value)Description copied from interface:StringMapPuts the specified key-value pair into the collection.
-
remove
public void remove(java.lang.String key)
Description copied from interface:StringMapRemoves the key-value pair for the specified key from this data structure.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
Description copied from interface:StringMapIndicates whether some other object is "equal to" this one.- Specified by:
equalsin interfaceStringMap- Overrides:
equalsin classjava.lang.Object- Parameters:
object- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
StringMap.hashCode()
-
-