Interface ThreadContextMap

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void clear()
      Clears the context.
      boolean containsKey​(String key)
      Determines if the key is in the context.
      String get​(String key)
      Gets the context identified by the key parameter.
      Map<String,​String> getCopy()
      Gets a non-null mutable copy of current thread's context Map.
      Map<String,​String> getImmutableMapOrNull()
      Returns an immutable view on the context Map or null if the context map is empty.
      default StringMap getReadOnlyContextData()
      Returns the context data for reading.
      default <V> V getValue​(String key)
      Returns the Object value for the specified key, or null if the specified key does not exist in this collection.
      boolean isEmpty()
      Returns true if the Map is empty.
      void put​(String key, String value)
      Puts a context value (the o parameter) as identified with the key parameter into the current thread's context map.
      default void putAll​(Map<String,​String> map)
      Puts all given context map entries into the current thread's context map.
      default <V> void putAllValues​(Map<String,​V> values)
      Puts all given key-value pairs into the collection.
      default <V> void putValue​(String key, V value)
      Puts the specified key-value pair into the collection.
      void remove​(String key)
      Removes the context identified by the key parameter.
      default void removeAll​(Iterable<String> keys)
      Removes all given context map keys from the current thread's context map.
    • Method Detail

      • clear

        void clear()
        Clears the context.
      • containsKey

        boolean containsKey​(String key)
        Determines if the key is in the context.
        Parameters:
        key - The key to locate.
        Returns:
        True if the key is in the context, false otherwise.
      • get

        String get​(String key)
        Gets the context identified by the key parameter.

        This method has no side effects.

        Parameters:
        key - The key to locate.
        Returns:
        The value associated with the key or null.
      • getCopy

        Map<String,​String> getCopy()
        Gets a non-null mutable copy of current thread's context Map.
        Returns:
        a mutable copy of the context.
      • getImmutableMapOrNull

        Map<String,​String> getImmutableMapOrNull()
        Returns an immutable view on the context Map or null if the context map is empty.
        Returns:
        an immutable context Map or null.
      • isEmpty

        boolean isEmpty()
        Returns true if the Map is empty.
        Returns:
        true if the Map is empty, false otherwise.
      • put

        void put​(String key,
                 String value)
        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.

        Parameters:
        key - The key name.
        value - The key value.
      • remove

        void remove​(String key)
        Removes the context identified by the key parameter.
        Parameters:
        key - The key to remove.
      • putAll

        default void putAll​(Map<String,​String> map)
        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.

        Parameters:
        map - The map.
        Since:
        3.0.0
      • getReadOnlyContextData

        default StringMap getReadOnlyContextData()
        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.
        Returns:
        the StringMap
        Since:
        3.0.0
      • removeAll

        default void removeAll​(Iterable<String> keys)
        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.

        Parameters:
        keys - The keys.
        Since:
        3.0.0
      • getValue

        default <V> V getValue​(String key)
        Returns the Object value for the specified key, or null if the specified key does not exist in this collection.
        Type Parameters:
        V - The type of the returned value.
        Parameters:
        key - the key whose value to return
        Returns:
        the value for the specified key or null
        Since:
        3.0.0
      • putValue

        default <V> void putValue​(String key,
                                  V value)
        Puts the specified key-value pair into the collection.
        Type Parameters:
        V - The type of the stored and returned value.
        Parameters:
        key - the key to add or remove. Keys may be null.
        value - the value to add. Values may be null.
        Since:
        3.0.0
      • putAllValues

        default <V> void putAllValues​(Map<String,​V> values)
        Puts all given key-value pairs into the collection.
        Type Parameters:
        V - The type of the value being added.
        Parameters:
        values - the map of key-value pairs to add
        Since:
        3.0.0