Class MDCContextMap

    • Constructor Summary

      Constructors 
      Constructor Description
      MDCContextMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears the context.
      boolean containsKey​(java.lang.String key)
      Determines if the key is in the context.
      java.lang.String get​(java.lang.String key)
      Gets the context identified by the key parameter.
      java.util.Map<java.lang.String,​java.lang.String> getCopy()
      Gets a non-null mutable copy of current thread's context Map.
      java.util.Map<java.lang.String,​java.lang.String> getImmutableMapOrNull()
      Returns an immutable view on the context Map or null if the context map is empty.
      StringMap getReadOnlyContextData()
      Returns the context data for reading.
      boolean isEmpty()
      Returns true if the Map is empty.
      void put​(java.lang.String key, java.lang.String value)
      Puts a context value (the o parameter) as identified with the key parameter into the current thread's context map.
      void putAll​(java.util.Map<java.lang.String,​java.lang.String> m)
      Puts all given context map entries into the current thread's context map.
      void remove​(java.lang.String key)
      Removes the context identified by the key parameter.
      void removeAll​(java.lang.Iterable<java.lang.String> keys)
      Removes all given context map keys from the current thread's context map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_CONTEXT_DATA

        private static final StringMap EMPTY_CONTEXT_DATA
    • Constructor Detail

      • MDCContextMap

        public MDCContextMap()
    • Method Detail

      • put

        public void put​(java.lang.String key,
                        java.lang.String value)
        Description copied from interface: ThreadContextMap
        Puts a context value (the o parameter) as identified with the key 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 interface ThreadContextMap
        Parameters:
        key - The key name.
        value - The key value.
      • putAll

        public void putAll​(java.util.Map<java.lang.String,​java.lang.String> m)
        Description copied from interface: ThreadContextMap2
        Puts all given context map entries 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:
        putAll in interface ThreadContextMap2
        Parameters:
        m - The map.
      • get

        public java.lang.String get​(java.lang.String key)
        Description copied from interface: ThreadContextMap
        Gets the context identified by the key parameter.

        This method has no side effects.

        Specified by:
        get in interface ThreadContextMap
        Parameters:
        key - The key to locate.
        Returns:
        The value associated with the key or null.
      • remove

        public void remove​(java.lang.String key)
        Description copied from interface: ThreadContextMap
        Removes the context identified by the key parameter.
        Specified by:
        remove in interface ThreadContextMap
        Parameters:
        key - The key to remove.
      • removeAll

        public void removeAll​(java.lang.Iterable<java.lang.String> keys)
        Description copied from interface: CleanableThreadContextMap
        Removes all given context map keys from 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:
        removeAll in interface CleanableThreadContextMap
        Parameters:
        keys - The keys.
      • containsKey

        public boolean containsKey​(java.lang.String key)
        Description copied from interface: ThreadContextMap
        Determines if the key is in the context.
        Specified by:
        containsKey in interface ThreadContextMap
        Parameters:
        key - The key to locate.
        Returns:
        True if the key is in the context, false otherwise.
      • getCopy

        public java.util.Map<java.lang.String,​java.lang.String> getCopy()
        Description copied from interface: ThreadContextMap
        Gets a non-null mutable copy of current thread's context Map.
        Specified by:
        getCopy in interface ThreadContextMap
        Returns:
        a mutable copy of the context.
      • getImmutableMapOrNull

        public java.util.Map<java.lang.String,​java.lang.String> getImmutableMapOrNull()
        Description copied from interface: ThreadContextMap
        Returns an immutable view on the context Map or null if the context map is empty.
        Specified by:
        getImmutableMapOrNull in interface ThreadContextMap
        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 interface ThreadContextMap
        Returns:
        true if the Map is empty, false otherwise.
      • getReadOnlyContextData

        public StringMap getReadOnlyContextData()
        Description copied from interface: ThreadContextMap2
        Returns the context data for reading. Note that regardless of whether the returned context data has been frozen (made read-only) or not, callers should not attempt to modify the returned data structure.
        Specified by:
        getReadOnlyContextData in interface ThreadContextMap2
        Returns:
        the StringMap