Class Metadata
Message.
Typically, the metadata contains information about the message payload that isn't "domain-specific." Examples are originating IP-address or executing User ID.
- Since:
- 2.0.0
- Author:
- Allard Buijze
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns aMetadatainstance containing the current entries, and the givenkeyand givenvalue.andIfNotPresent(String key, Supplier<String> value) Returns aMetadatainstance containing the current entries, and the givenkeyif it was not yet present in thisMetadata.voidclear()This operation is not supported sinceMetadatais an immutable object.booleancontainsKey(Object key) booleancontainsValue(Object value) static MetadataReturns an emptyMetadatainstance.entrySet()booleanstatic MetadataCreates a newMetadatainstance from the givenmetadataEntries.inthashCode()booleanisEmpty()keySet()mergedWith(Map<String, String> additionalEntries) Returns aMetadatainstance containing values ofthis, combined with the givenadditionalEntries.This operation is not supported sinceMetadatais an immutable object.voidThis operation is not supported sinceMetadatais an immutable object.This operation is not supported sinceMetadatais an immutable object.intsize()Returns aMetadatainstance containing a subset of thekeysin this instance.toString()values()static MetadataCreates aMetadatainstance with a single entry from the givenkeyand givenvalue.withoutKeys(Set<String> keys) Returns aMetadatainstance for which the entries with givenkeysare removed.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
Metadata
Initializes aMetadatainstance with the givenitemsas content.Note that the items are copied into the
Metadata. Modifications in theMapof items will not reflect is theMetadata, or vice versa. Modifications in the items themselves are reflected in theMetadata.- Parameters:
items- The items to populate theMetadatawith.
-
-
Method Details
-
emptyInstance
Returns an emptyMetadatainstance.- Returns:
- An empty
Metadatainstance.
-
from
Creates a newMetadatainstance from the givenmetadataEntries.If
metadataEntriesis already aMetadatainstance, it is returned as is. This makes this method more suitable than theMetadata(java.util.Map)copy-constructor.- Parameters:
metadataEntries- The entries to populate theMetadatawith.- Returns:
- A
MetadataData instance with the givenMetadataEntriesas content.
-
with
Creates aMetadatainstance with a single entry from the givenkeyand givenvalue.- Parameters:
key- The key for the entry.value- The value of the entry.- Returns:
- A
Metadatainstance with a single entry.
-
and
Returns aMetadatainstance containing the current entries, and the givenkeyand givenvalue.If
keyalready existed, it's oldvalueis overwritten with the givenvalue.- Parameters:
key- The key for the entry.value- The value of the entry.- Returns:
- A
Metadatainstance with an additional entry.
-
andIfNotPresent
Returns aMetadatainstance containing the current entries, and the givenkeyif it was not yet present in thisMetadata.If the given
keyalready existed, the current value will be used. Otherwise, thevalueSupplierfunction will provide the value forkey.- Parameters:
key- The key for the entry.value- ASupplierfunction which provides the value.- Returns:
- A
Metadatainstance with an additional entry.
-
mergedWith
Returns aMetadatainstance containing values ofthis, combined with the givenadditionalEntries.If any entries have identical keys, the values from the
additionalEntrieswill take precedence.- Parameters:
additionalEntries- The additional entries for the newMetadata.- Returns:
- A
Metadatainstance containing values ofthis, combined with the givenadditionalEntries.
-
withoutKeys
Returns aMetadatainstance for which the entries with givenkeysare removed.Keys for which there is no assigned value are ignored. This
Metadatainstance is not influenced by this operation.- Parameters:
keys- The keys of the entries to remove.- Returns:
- A
Metadatainstance without the givenkeys.
-
subset
Returns aMetadatainstance containing a subset of thekeysin this instance.Keys for which there is no assigned value are ignored. This
Metadatainstance is not influenced by this operation.- Parameters:
keys- The keys of the entries to remove.- Returns:
- A
Metadatainstance containing the givenkeysif these were already present.
-
get
-
put
This operation is not supported sinceMetadatais an immutable object. -
remove
This operation is not supported sinceMetadatais an immutable object. -
putAll
This operation is not supported sinceMetadatais an immutable object. -
clear
public void clear()This operation is not supported sinceMetadatais an immutable object. -
containsKey
- Specified by:
containsKeyin interfaceMap<String,String>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,String>
-
keySet
-
values
-
entrySet
-
size
public int size() -
isEmpty
public boolean isEmpty() -
equals
-
hashCode
public int hashCode() -
toString
-