org.axonframework.domain
Class MetaData

java.lang.Object
  extended by org.axonframework.domain.MetaData
All Implemented Interfaces:
Serializable, Map<String,Object>

public class MetaData
extends Object
implements Map<String,Object>, Serializable

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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MetaData(Map<String,?> items)
          Initializes a MetaData instance with the given items as content.
 
Method Summary
 void clear()
          This operation is not supported.

 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
static MetaData emptyInstance()
          Returns an empty MetaData instance.
 Set<Map.Entry<String,Object>> entrySet()
           
 boolean equals(Object o)
           
static MetaData from(Map<String,?> metaDataEntries)
          Creates a new MetaData instance from the given metaDataEntries.
 Object get(Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Set<String> keySet()
           
 MetaData mergedWith(Map<String,?> additionalEntries)
          Returns a MetaData instance containing values of this, combined with the given additionalEntries.
 Object put(String key, Object value)
          This operation is not supported.

 void putAll(Map<? extends String,?> m)
          This operation is not supported.

protected  Object readResolve()
          Java Serialization specification method that will ensure that deserialization will maintain a single instance of empty MetaData.
 Object remove(Object key)
          This operation is not supported.

 int size()
           
 Collection<Object> values()
           
 MetaData withoutKeys(Set<String> keys)
          Returns a MetaData instance with the items with given keys removed.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaData

public MetaData(Map<String,?> items)
Initializes a MetaData instance with the given items as 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 Detail

emptyInstance

public static MetaData emptyInstance()
Returns an empty MetaData instance.

Returns:
an empty MetaData instance

from

public static MetaData from(Map<String,?> metaDataEntries)
Creates a new MetaData instance from the given metaDataEntries. If metaDataEntries is already a MetaData instance, it is returned as is. This makes this method more suitable than the MetaData(java.util.Map) copy-constructor.

Parameters:
metaDataEntries - the items to populate the MetaData with
Returns:
a MetaData instance with the given metaDataEntries as content

get

public Object get(Object key)
Specified by:
get in interface Map<String,Object>

put

public Object put(String key,
                  Object value)
This operation is not supported.

Specified by:
put in interface Map<String,Object>

remove

public Object remove(Object key)
This operation is not supported.

Specified by:
remove in interface Map<String,Object>

putAll

public void putAll(Map<? extends String,?> m)
This operation is not supported.

Specified by:
putAll in interface Map<String,Object>

clear

public void clear()
This operation is not supported.

Specified by:
clear in interface Map<String,Object>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,Object>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<String,Object>

keySet

public Set<String> keySet()
Specified by:
keySet in interface Map<String,Object>

values

public Collection<Object> values()
Specified by:
values in interface Map<String,Object>

entrySet

public Set<Map.Entry<String,Object>> entrySet()
Specified by:
entrySet in interface Map<String,Object>

size

public int size()
Specified by:
size in interface Map<String,Object>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<String,Object>

equals

public boolean equals(Object o)
Specified by:
equals in interface Map<String,Object>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<String,Object>
Overrides:
hashCode in class Object

mergedWith

public MetaData mergedWith(Map<String,?> additionalEntries)
Returns a MetaData instance containing values of this, combined with the given additionalEntries. If any entries have identical keys, the values from the additionalEntries will take precedence.

Parameters:
additionalEntries - The additional entries for the new MetaData
Returns:
a MetaData instance containing values of this, combined with the given additionalEntries

withoutKeys

public MetaData withoutKeys(Set<String> keys)
Returns a MetaData instance with the items with given keys removed. 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

readResolve

protected Object 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


Copyright © 2010-2016. All Rights Reserved.