Class ContextMap.Key<T>

java.lang.Object
io.servicetalk.context.api.ContextMap.Key<T>
Type Parameters:
T - The type of value associated with a ContextMap.Key.
Enclosing interface:
ContextMap

public static final class ContextMap.Key<T> extends Object
A key identifies a specific object in a ContextMap.

Comparison between ContextMap.Key objects should be assumed to be on an instance basis. In general, newKey(strA, typeA) != newKey(strA, typeA).

  • Method Details

    • name

      public String name()
      Returns the name of the key.
      Returns:
      the name of the key.
    • type

      public Class<T> type()
      Returns the type of the key.
      Returns:
      the type of the key.
    • newKey

      public static <T> ContextMap.Key<T> newKey(String name, Class<T> type)
      Creates a new ContextMap.Key with the specified name and type.
      Type Parameters:
      T - The value type associated with the ContextMap.Key.
      Parameters:
      name - The name of the key. This WILL NOT be used in comparisons between ContextMap.Key objects.
      type - The type of the key. This WILL NOT be used in comparisons between ContextMap.Key objects.
      Returns:
      A new ContextMap.Key which uses a passed name only in the toString() method for debugging visibility.
    • toString

      public String toString()
      Overrides:
      toString in class Object