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 creates new instances using the
of(Object...)
andfrom(Iterable)
methods.IMPORTANT: Experimental.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Metadata
copy()
Copies the currentMetadata
instance.static Metadata
empty()
Returns an empty set of metadata.static Metadata
from(Iterable<Object> metadata)
Returns an instance ofMetadata
containing multiple values.<T> Optional<T>
get(Class<T> clazz)
Retrieves the metadata associated with given class.Iterator<Object>
iterator()
static Metadata
of(Object... metadata)
Returns an instance ofMetadata
containing multiple values.Metadata
with(Object item)
Creates a new instance ofMetadata
with the current entries, plusitem
.Metadata
without(Class<?> clazz)
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 Detail
-
empty
public static Metadata empty()
Returns an empty set of metadata.- Returns:
- the empty instance
-
of
public static Metadata of(Object... metadata)
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
public static Metadata from(Iterable<Object> metadata)
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
public Metadata with(Object item)
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
public Metadata without(Class<?> clazz)
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
-
get
public <T> Optional<T> get(Class<T> clazz)
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.
-
-