Package org.apache.logging.log4j
Class ThreadContext.EmptyThreadContextStack
- All Implemented Interfaces:
Serializable
,Iterable<String>
,Collection<String>
,ThreadContextStack
,ThreadContext.ContextStack
- Enclosing class:
- ThreadContext
private static class ThreadContext.EmptyThreadContextStack
extends AbstractCollection<String>
implements ThreadContextStack
An empty read-only ThreadContextStack.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends String> c) asList()
Returns all the elements in the stack in a List.boolean
containsAll
(Collection<?> c) copy()
Returns a copy of the ContextStack.boolean
int
getDepth()
Returns the number of elements in the stack.Returns a ContextStack with the same contents as this ContextStack ornull
.int
hashCode()
iterator()
peek()
Returns the element at the top of the stack without removing it or null if the stack is empty.pop()
Returns the element at the top of the stack.void
Pushes an element onto the stack.boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
<T> T[]
toArray
(T[] a) void
trim
(int depth) Trims elements from the end of the stack.Methods inherited from class java.util.AbstractCollection
clear, contains, isEmpty, remove, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
clear, contains, isEmpty, parallelStream, remove, removeIf, spliterator, stream, toArray, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
EMPTY_ITERATOR
-
-
Constructor Details
-
EmptyThreadContextStack
private EmptyThreadContextStack()
-
-
Method Details
-
pop
Description copied from interface:ThreadContext.ContextStack
Returns the element at the top of the stack.- Specified by:
pop
in interfaceThreadContext.ContextStack
- Returns:
- The element at the top of the stack.
-
peek
Description copied from interface:ThreadContext.ContextStack
Returns the element at the top of the stack without removing it or null if the stack is empty.- Specified by:
peek
in interfaceThreadContext.ContextStack
- Returns:
- the element at the top of the stack or null if the stack is empty.
-
push
Description copied from interface:ThreadContext.ContextStack
Pushes an element onto the stack.- Specified by:
push
in interfaceThreadContext.ContextStack
- Parameters:
message
- The element to add.
-
getDepth
public int getDepth()Description copied from interface:ThreadContext.ContextStack
Returns the number of elements in the stack.- Specified by:
getDepth
in interfaceThreadContext.ContextStack
- Returns:
- the number of elements in the stack.
-
asList
Description copied from interface:ThreadContext.ContextStack
Returns all the elements in the stack in a List.- Specified by:
asList
in interfaceThreadContext.ContextStack
- Returns:
- all the elements in the stack in a List.
-
trim
public void trim(int depth) Description copied from interface:ThreadContext.ContextStack
Trims elements from the end of the stack.- Specified by:
trim
in interfaceThreadContext.ContextStack
- Parameters:
depth
- The maximum number of items in the stack to keep.
-
equals
- Specified by:
equals
in interfaceCollection<String>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<String>
- Overrides:
hashCode
in classObject
-
copy
Description copied from interface:ThreadContext.ContextStack
Returns a copy of the ContextStack.- Specified by:
copy
in interfaceThreadContext.ContextStack
- Returns:
- a copy of the ContextStack.
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<String>
- Overrides:
toArray
in classAbstractCollection<String>
-
add
- Specified by:
add
in interfaceCollection<String>
- Overrides:
add
in classAbstractCollection<String>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<String>
- Overrides:
containsAll
in classAbstractCollection<String>
-
addAll
- Specified by:
addAll
in interfaceCollection<String>
- Overrides:
addAll
in classAbstractCollection<String>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<String>
- Overrides:
removeAll
in classAbstractCollection<String>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<String>
- Overrides:
retainAll
in classAbstractCollection<String>
-
iterator
- Specified by:
iterator
in interfaceCollection<String>
- Specified by:
iterator
in interfaceIterable<String>
- Specified by:
iterator
in classAbstractCollection<String>
-
size
public int size()- Specified by:
size
in interfaceCollection<String>
- Specified by:
size
in classAbstractCollection<String>
-
getImmutableStackOrNull
Description copied from interface:ThreadContext.ContextStack
Returns a ContextStack with the same contents as this ContextStack ornull
. Attempts to modify the returned stack may or may not throw an exception, but will not affect the contents of this ContextStack.- Specified by:
getImmutableStackOrNull
in interfaceThreadContext.ContextStack
- Returns:
- a ContextStack with the same contents as this ContextStack or
null
.
-