@Experimental(value="metadata propagation is a SmallRye-specific feature") public class Metadata extends Object implements Iterable<Object>
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...)
and from(Iterable)
methods.
IMPORTANT: Experimental.
Modifier and Type | Method and Description |
---|---|
Metadata |
copy()
Copies the current
Metadata instance. |
static Metadata |
empty()
Returns an empty set of metadata.
|
static Metadata |
from(Iterable<Object> metadata)
Returns an instance of
Metadata 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 of
Metadata containing multiple values. |
Metadata |
with(Object item)
Creates a new instance of
Metadata with the current entries, plus item . |
Metadata |
without(Class<?> clazz)
Creates a new instance of
Metadata with the current entries, minus the entry associated with the given class. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static Metadata empty()
public static Metadata of(Object... metadata)
Metadata
containing multiple values.metadata
- the metadata, must not be null
, must not contain null
,
must not contain multiple objects of the same classpublic static Metadata from(Iterable<Object> metadata)
Metadata
containing multiple values.metadata
- the metadata, must not be null
, must not contain null
,
must not contain multiple objects of the same classpublic Metadata with(Object item)
Metadata
with the current entries, plus item
.
If the current set of metadata contains already an instance of the class of item
, the value is replaced
in the returned Metadata
.item
- the metadata to be added, must not be null
.Metadata
public Metadata without(Class<?> clazz)
Metadata
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.clazz
- instance from this class are removed from the metadata.Metadata
public <T> Optional<T> get(Class<T> clazz)
clazz
- the class of the metadata to retrieve, must not be null
Optional
containing the associated metadata, empty if none.Copyright © 2018–2021 SmallRye. All rights reserved.