Class GenericMessage<T>
- java.lang.Object
- org.springframework.messaging.support.GenericMessage<T>
- All Implemented Interfaces:
Serializable
,Message<T>
- Direct Known Subclasses:
ErrorMessage
public class GenericMessage<T> extends Object implements Message<T>, Serializable
An implementation ofMessage
with a generic payload. Once created, a GenericMessage is immutable.- Since:
- 4.0
- Author:
- Mark Fisher
- See Also:
MessageBuilder
, Serialized Form
Constructor Summary
Constructors Constructor Description GenericMessage(T payload)
Create a new message with the given payload.GenericMessage(T payload, Map<String,Object> headers)
Create a new message with the given payload and headers.GenericMessage(T payload, MessageHeaders headers)
A constructor with theMessageHeaders
instance to use.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
MessageHeaders
getHeaders()
Return message headers for the message (nevernull
but may be empty).T
getPayload()
Return the message payload.int
hashCode()
String
toString()
Constructor Detail
GenericMessage
public GenericMessage(T payload)
Create a new message with the given payload.- Parameters:
payload
- the message payload (nevernull
)
GenericMessage
public GenericMessage(T payload, Map<String,Object> headers)
Create a new message with the given payload and headers. The content of the given header map is copied.- Parameters:
payload
- the message payload (nevernull
)headers
- message headers to use for initialization
GenericMessage
public GenericMessage(T payload, MessageHeaders headers)
A constructor with theMessageHeaders
instance to use.Note: the given
MessageHeaders
instance is used directly in the new message, i.e. it is not copied.- Parameters:
payload
- the message payload (nevernull
)headers
- message headers
Method Detail
getPayload
public T getPayload()
Description copied from interface:Message
Return the message payload.- Specified by:
getPayload
in interfaceMessage<T>
getHeaders
public MessageHeaders getHeaders()
Description copied from interface:Message
Return message headers for the message (nevernull
but may be empty).- Specified by:
getHeaders
in interfaceMessage<T>