Package io.smallrye.reactive.messaging
Class GenericPayload<T>
java.lang.Object
io.smallrye.reactive.messaging.GenericPayload<T>
- Type Parameters:
T- the type of the payload
A generic payload that can be used to wrap a payload with metadata.
Allows associating a payload with metadata to be sent as a message,
without using signatures supporting
Message<T>.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> GenericPayload<T> Creates a new payload from the given message.Gets the metadata associated with this payload.Gets the payload associated with this payload.static <T> GenericPayload<T> of(T payload) Creates a new payload with the given payload and empty metadata.static <T> GenericPayload<T> Creates a new payload with the given payload and metadata.Converts this payload to a message.Converts this payload to a message, merging the metadata with the given message.withMetadata(Metadata metadata) Adds metadata to this payload.<R> GenericPayload<R> withPayload(R payload) Adds metadata to this payload.
-
Constructor Details
-
GenericPayload
-
-
Method Details
-
of
Creates a new payload with the given payload and empty metadata.- Type Parameters:
T- the type of the payload- Parameters:
payload- the payload- Returns:
- the payload
-
of
Creates a new payload with the given payload and metadata.- Type Parameters:
T- the type of the payload- Parameters:
payload- the payloadmetadata- the metadata- Returns:
- the payload
-
from
Creates a new payload from the given message.- Type Parameters:
T- the type of the payload- Parameters:
message- the message- Returns:
- the payload
-
getPayload
Gets the payload associated with this payload.- Returns:
- the payload
-
getMetadata
Gets the metadata associated with this payload.- Returns:
- the metadata
-
withMetadata
Adds metadata to this payload.- Parameters:
metadata- the metadata to add- Returns:
- a new payload with the added metadata
-
withPayload
Adds metadata to this payload.- Parameters:
payload- the payload to add- Returns:
- a new payload with the added metadata
-
toMessage
Converts this payload to a message.- Returns:
- the message with the payload and metadata
-
toMessage
Converts this payload to a message, merging the metadata with the given message.- Parameters:
message- the message to merge the metadata with- Returns:
- the message with the payload and merged metadata
-