Class Metadata
java.lang.Object
org.eclipse.microprofile.reactive.messaging.Metadata
@Experimental("metadata propagation is a SmallRye-specific feature")
public class Metadata
extends Object
implements Iterable<Object>
Message metadata containers.
This class stores message metadata that can be related to the transport layer or to the business / application.
Instances of this class are immutable. Modification operation returned new instances. Contained instances are not constrained, but should be immutable. Only one instance of each class can be stored, as the class is used to retrieve the metadata.
You can create new instances using the of(Object...)
and from(Iterable)
methods.
IMPORTANT: Experimental.
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copies the currentMetadata
instance.static Metadata
empty()
Returns an empty set of metadata.static Metadata
Returns an instance ofMetadata
containing multiple values.<T> Optional<T>
Retrieves the metadata associated with given class.iterator()
static Metadata
Returns an instance ofMetadata
containing multiple values.Creates a new instance ofMetadata
with the current entries, plusitem
.Creates a new instance ofMetadata
with the current entries, minus the entry associated with the given class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
empty
Returns an empty set of metadata.- Returns:
- the empty instance
-
of
Returns an instance ofMetadata
containing multiple values.- Parameters:
metadata
- the metadata, must not benull
, must not containnull
, must not contain multiple objects of the same class- Returns:
- the new metadata
-
from
Returns an instance ofMetadata
containing multiple values.- Parameters:
metadata
- the metadata, must not benull
, must not containnull
, must not contain multiple objects of the same class- Returns:
- the new metadata
-
with
Creates a new instance ofMetadata
with the current entries, plusitem
. If the current set of metadata contains already an instance of the class ofitem
, the value is replaced in the returnedMetadata
.- Parameters:
item
- the metadata to be added, must not benull
.- Returns:
- the new instance of
Metadata
-
without
Creates a new instance ofMetadata
with the current entries, minus the entry associated with the given class. If there is no instance of the class in the current set of metadata, the same entries are composing returned instance of metadata.- Parameters:
clazz
- instance from this class are removed from the metadata.- Returns:
- the new instance of
Metadata
-
copy
Copies the currentMetadata
instance.- Returns:
- the new instance.
-
get
Retrieves the metadata associated with given class.- Parameters:
clazz
- the class of the metadata to retrieve, must not benull
- Returns:
- an
Optional
containing the associated metadata, empty if none.
-
iterator
-