T
- the payload typepublic class GenericMessage<T> extends java.lang.Object implements Message<T>, java.io.Serializable
Message
with a generic payload.
Once created, a GenericMessage is immutable.MessageBuilder
,
Serialized FormModifier and Type | Field and Description |
---|---|
private MessageHeaders |
headers |
private T |
payload |
private static long |
serialVersionUID |
Constructor and Description |
---|
GenericMessage(T payload)
Create a new message with the given payload.
|
GenericMessage(T payload,
java.util.Map<java.lang.String,java.lang.Object> headers)
Create a new message with the given payload and headers.
|
GenericMessage(T payload,
MessageHeaders headers)
A constructor with the
MessageHeaders instance to use. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
MessageHeaders |
getHeaders()
Return message headers for the message (never
null but may be empty). |
T |
getPayload()
Return the message payload.
|
int |
hashCode() |
java.lang.String |
toString() |
private static final long serialVersionUID
private final T payload
private final MessageHeaders headers
public GenericMessage(T payload)
payload
- the message payload (never null
)public GenericMessage(T payload, java.util.Map<java.lang.String,java.lang.Object> headers)
payload
- the message payload (never null
)headers
- message headers to use for initializationpublic GenericMessage(T payload, MessageHeaders headers)
MessageHeaders
instance to use.
Note: the given MessageHeaders
instance is used
directly in the new message, i.e. it is not copied.
payload
- the message payload (never null
)headers
- message headerspublic T getPayload()
Message
getPayload
in interface Message<T>
public MessageHeaders getHeaders()
Message
null
but may be empty).getHeaders
in interface Message<T>
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object