Class ContextMetadata
- java.lang.Object
-
- com.google.common.flogger.backend.Metadata
-
- com.google.common.flogger.context.ContextMetadata
-
public abstract class ContextMetadata extends Metadata
ImmutableMetadataimplementation 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 ofScopedLoggingContextand should not be considered a stable API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classContextMetadata.BuilderA builder to collect metadata key/values pairs in order.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ContextMetadata.Builderbuilder()Returns a newScopeMetadatabuilder.abstract ContextMetadataconcatenate(ContextMetadata metadata)Concatenates the given context metadata after this instance.MetadataKey<?>getKey(int n)Returns the key for the Nth piece of metadata.ObjectgetValue(int n)Returns the non-null value for the Nth piece of metadata.static ContextMetadatanone()Returns the emptyScopeMetadata.static <T> ContextMetadatasingleton(MetadataKey<T> key, T value)Returns a space efficientScopeMetadatacontaining a single value.
-
-
-
Method Detail
-
builder
public static ContextMetadata.Builder builder()
Returns a newScopeMetadatabuilder.
-
singleton
public static <T> ContextMetadata singleton(MetadataKey<T> key, T value)
Returns a space efficientScopeMetadatacontaining a single value.
-
none
public static ContextMetadata none()
Returns the emptyScopeMetadata.
-
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
MetadataProcessorto process metadata consistently with respect to single valued and repeated keys, and useMetadata.findValue(MetadataKey)to lookup the "most recent" value for a single valued key.
-
getKey
public MetadataKey<?> getKey(int n)
Description copied from class:MetadataReturns the key for the Nth piece of metadata.
-
-