Package org.axonframework.messaging
Class MetaData
java.lang.Object
org.axonframework.messaging.MetaData
- All Implemented Interfaces:
Serializable,Map<String,Object>
Represents MetaData that is passed along with a payload in a 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
- Author:
- Allard Buijze
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a MetaData instances containing the current entries, and the givenkeyand givenvalue.andIfNotPresent(String key, Supplier<Object> value) Returns a MetaData instances containing the current entries, and the givenkeyif it was not yet present in this MetaData.voidclear()This operation is not supported.booleancontainsKey(Object key) booleancontainsValue(Object value) static MetaDataReturns an empty MetaData instance.entrySet()booleanstatic MetaDataCreates a new MetaData instance from the givenmetaDataEntries.inthashCode()booleanisEmpty()keySet()mergedWith(Map<String, ?> additionalEntries) Returns a MetaData instance containing values ofthis, combined with the givenadditionalEntries.This operation is not supported.voidThis operation is not supported.protected ObjectJava Serialization specification method that will ensure that deserialization will maintain a single instance of empty MetaData.This operation is not supported.intsize()Returns a MetaData instance containing a subset of thekeysin this instance.toString()values()static MetaDataCreates a MetaData instances with a single entry, with the givenkeyand givenvalue.withoutKeys(Set<String> keys) Returns a MetaData instance with the items with givenkeysremoved.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 a MetaData instance with the givenitemsas content. Note that the items are copied into the MetaData. Modifications in the Map of items will not reflect is the MetaData, or vice versa. Modifications in the items themselves are reflected in the MetaData.- Parameters:
items- the items to populate the MetaData with
-
-
Method Details
-
emptyInstance
Returns an empty MetaData instance.- Returns:
- an empty MetaData instance
-
from
Creates a new MetaData instance from the givenmetaDataEntries. IfmetaDataEntriesis already a MetaData instance, it is returned as is. This makes this method more suitable than theMetaData(java.util.Map)copy-constructor.- Parameters:
metaDataEntries- the items to populate the MetaData with- Returns:
- a MetaData instance with the given
metaDataEntriesas content
-
with
Creates a MetaData instances with a single entry, with the givenkeyand givenvalue.- Parameters:
key- The key for the entryvalue- The value of the entry- Returns:
- a MetaData instance with a single entry
-
and
Returns a MetaData instances containing the current entries, and the givenkeyand givenvalue. Ifkeyalready existed, it's oldvalueis overwritten with the givenvalue.- Parameters:
key- The key for the entryvalue- The value of the entry- Returns:
- a MetaData instance with an additional entry
-
andIfNotPresent
Returns a MetaData instances containing the current entries, and the givenkeyif it was not yet present in this MetaData. Ifkeyalready existed, the current value will be used. Otherwise the Supplier function will provide thevalueforkey- Parameters:
key- The key for the entryvalue- A Supplier function which provides the value- Returns:
- a MetaData instance with an additional entry
-
get
-
put
This operation is not supported. -
remove
This operation is not supported. -
putAll
This operation is not supported. -
clear
public void clear()This operation is not supported. -
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
keySet
-
values
-
entrySet
-
size
public int size() -
isEmpty
public boolean isEmpty() -
equals
-
hashCode
public int hashCode() -
mergedWith
Returns a MetaData instance containing values ofthis, combined with the givenadditionalEntries. If any entries have identical keys, the values from theadditionalEntrieswill take precedence.- Parameters:
additionalEntries- The additional entries for the new MetaData- Returns:
- a MetaData instance containing values of
this, combined with the givenadditionalEntries
-
withoutKeys
Returns a MetaData instance with the items with givenkeysremoved. Keys for which there is no assigned value are ignored.
This MetaData instance is not influenced by this operation.- Parameters:
keys- The keys of the entries to remove- Returns:
- a MetaData instance without the given
keys
-
subset
Returns a MetaData instance containing a subset of thekeysin this instance. Keys for which there is no assigned value are ignored.invalid input: '<'- Parameters:
keys- The keys of the entries to remove- Returns:
- a MetaData instance containing the given
keysif these were already present
-
readResolve
Java Serialization specification method that will ensure that deserialization will maintain a single instance of empty MetaData.- Returns:
- the MetaData instance to use after deserialization
-
toString
-