Class ContextMetadata


  • public abstract class ContextMetadata
    extends Metadata
    Immutable Metadata implementation intended for use in nested contexts. Scope metadata can be concatenated to inherit metadata from a parent context. This class is only expected to be needed by implementations of ScopedLoggingContext and should not be considered a stable API.
    • Method Detail

      • singleton

        public static <T> ContextMetadata singleton​(MetadataKey<T> key,
                                                    T value)
        Returns a space efficient ScopeMetadata containing a single value.
      • none

        public static ContextMetadata none()
        Returns the empty ScopeMetadata.
      • concatenate

        public abstract ContextMetadata concatenate​(ContextMetadata metadata)
        Concatenates the given context metadata after this instance. Key value pairs are simply concatenated (rather than being merged) which may result in multiple single valued keys existing in the resulting sequence.

        Whether this is achieved via copying or chaining of instances is an implementation detail.

        Use MetadataProcessor to process metadata consistently with respect to single valued and repeated keys, and use Metadata.findValue(MetadataKey) to lookup the "most recent" value for a single valued key.

      • getKey

        public MetadataKey<?> getKey​(int n)
        Description copied from class: Metadata
        Returns the key for the Nth piece of metadata.
        Specified by:
        getKey in class Metadata
      • getValue

        public Object getValue​(int n)
        Description copied from class: Metadata
        Returns the non-null value for the Nth piece of metadata.
        Specified by:
        getValue in class Metadata