Package org.apache.logging.log4j.spi
Class NoOpThreadContextMap
java.lang.Object
org.apache.logging.log4j.spi.NoOpThreadContextMap
- All Implemented Interfaces:
ThreadContextMap
ThreadContextMap
implementation used when either of system properties disableThreadContextMap
or .
disableThreadContext
is true
. This implementation does nothing.- Since:
- 2.7
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the context.boolean
containsKey
(String key) Determines if the key is in the context.@Nullable String
Gets the context identified by thekey
parameter.getCopy()
Gets a non-null
mutable copy of current thread's context Map.Returns an immutable view on the context Map ornull
if the context map is empty.boolean
isEmpty()
Returns true if the Map is empty.void
Puts a context value (theo
parameter) as identified with thekey
parameter into the current thread's context map.void
Removes the context identified by thekey
parameter.
-
Field Details
-
INSTANCE
- Since:
- 2.24.0
-
-
Constructor Details
-
NoOpThreadContextMap
public NoOpThreadContextMap()
-
-
Method Details
-
clear
public void clear()Description copied from interface:ThreadContextMap
Clears the context.- Specified by:
clear
in interfaceThreadContextMap
-
containsKey
Description copied from interface:ThreadContextMap
Determines if the key is in the context.- Specified by:
containsKey
in interfaceThreadContextMap
- Parameters:
key
- The key to locate.- Returns:
- True if the key is in the context, false otherwise.
-
get
Description copied from interface:ThreadContextMap
Gets the context identified by thekey
parameter.This method has no side effects.
- Specified by:
get
in interfaceThreadContextMap
- Parameters:
key
- The key to locate.- Returns:
- The value associated with the key or null.
-
getCopy
Description copied from interface:ThreadContextMap
Gets a non-null
mutable copy of current thread's context Map.- Specified by:
getCopy
in interfaceThreadContextMap
- Returns:
- a mutable copy of the context.
-
getImmutableMapOrNull
Description copied from interface:ThreadContextMap
Returns an immutable view on the context Map ornull
if the context map is empty.- Specified by:
getImmutableMapOrNull
in interfaceThreadContextMap
- Returns:
- an immutable context Map or
null
.
-
isEmpty
public boolean isEmpty()Description copied from interface:ThreadContextMap
Returns true if the Map is empty.- Specified by:
isEmpty
in interfaceThreadContextMap
- Returns:
- true if the Map is empty, false otherwise.
-
put
Description copied from interface:ThreadContextMap
Puts a context value (theo
parameter) as identified with thekey
parameter into the current thread's context map.If the current thread does not have a context map it is created as a side effect.
- Specified by:
put
in interfaceThreadContextMap
- Parameters:
key
- The key name.value
- The key value.
-
remove
Description copied from interface:ThreadContextMap
Removes the context identified by thekey
parameter.- Specified by:
remove
in interfaceThreadContextMap
- Parameters:
key
- The key to remove.
-