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 TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends String> c) asList()Returns all the elements in the stack in a List.booleancontainsAll(Collection<?> c) copy()Returns a copy of the ContextStack.booleanintgetDepth()Returns the number of elements in the stack.Returns a ContextStack with the same contents as this ContextStack ornull.inthashCode()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.voidPushes an element onto the stack.booleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()<T> T[]toArray(T[] a) voidtrim(int depth) Trims elements from the end of the stack.Methods inherited from class java.util.AbstractCollection
clear, contains, isEmpty, remove, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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.ContextStackReturns the element at the top of the stack.- Specified by:
popin interfaceThreadContext.ContextStack- Returns:
- The element at the top of the stack.
-
peek
Description copied from interface:ThreadContext.ContextStackReturns the element at the top of the stack without removing it or null if the stack is empty.- Specified by:
peekin interfaceThreadContext.ContextStack- Returns:
- the element at the top of the stack or null if the stack is empty.
-
push
Description copied from interface:ThreadContext.ContextStackPushes an element onto the stack.- Specified by:
pushin interfaceThreadContext.ContextStack- Parameters:
message- The element to add.
-
getDepth
public int getDepth()Description copied from interface:ThreadContext.ContextStackReturns the number of elements in the stack.- Specified by:
getDepthin interfaceThreadContext.ContextStack- Returns:
- the number of elements in the stack.
-
asList
Description copied from interface:ThreadContext.ContextStackReturns all the elements in the stack in a List.- Specified by:
asListin interfaceThreadContext.ContextStack- Returns:
- all the elements in the stack in a List.
-
trim
public void trim(int depth) Description copied from interface:ThreadContext.ContextStackTrims elements from the end of the stack.- Specified by:
trimin interfaceThreadContext.ContextStack- Parameters:
depth- The maximum number of items in the stack to keep.
-
equals
- Specified by:
equalsin interfaceCollection<String>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<String>- Overrides:
hashCodein classObject
-
copy
Description copied from interface:ThreadContext.ContextStackReturns a copy of the ContextStack.- Specified by:
copyin interfaceThreadContext.ContextStack- Returns:
- a copy of the ContextStack.
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<String>- Overrides:
toArrayin classAbstractCollection<String>
-
add
- Specified by:
addin interfaceCollection<String>- Overrides:
addin classAbstractCollection<String>
-
containsAll
- Specified by:
containsAllin interfaceCollection<String>- Overrides:
containsAllin classAbstractCollection<String>
-
addAll
- Specified by:
addAllin interfaceCollection<String>- Overrides:
addAllin classAbstractCollection<String>
-
removeAll
- Specified by:
removeAllin interfaceCollection<String>- Overrides:
removeAllin classAbstractCollection<String>
-
retainAll
- Specified by:
retainAllin interfaceCollection<String>- Overrides:
retainAllin classAbstractCollection<String>
-
iterator
- Specified by:
iteratorin interfaceCollection<String>- Specified by:
iteratorin interfaceIterable<String>- Specified by:
iteratorin classAbstractCollection<String>
-
size
public int size()- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein classAbstractCollection<String>
-
getImmutableStackOrNull
Description copied from interface:ThreadContext.ContextStackReturns 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:
getImmutableStackOrNullin interfaceThreadContext.ContextStack- Returns:
- a ContextStack with the same contents as this ContextStack or
null.
-