org.springframework.messaging.support

Class GenericMessage<T>

  • java.lang.Object
    • org.springframework.messaging.support.GenericMessage<T>
  • Type Parameters:
    T - the payload type
    All Implemented Interfaces:
    java.io.Serializable, Message<T>
    Direct Known Subclasses:
    ErrorMessage


    public class GenericMessage<T>
    extends java.lang.Object
    implements Message<T>, java.io.Serializable
    An implementation of Message 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 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.
    • Constructor Detail

      • GenericMessage

        public GenericMessage(T payload)
        Create a new message with the given payload.
        Parameters:
        payload - the message payload (never null)
      • GenericMessage

        public GenericMessage(T payload,
                              java.util.Map<java.lang.String,java.lang.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 (never null)
        headers - message headers to use for initialization
      • GenericMessage

        public GenericMessage(T payload,
                              MessageHeaders headers)
        A constructor with the MessageHeaders 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 (never null)
        headers - message headers
    • Method Detail

      • getPayload

        public T getPayload()
        Description copied from interface: Message
        Return the message payload.
        Specified by:
        getPayload in interface Message<T>
      • getHeaders

        public MessageHeaders getHeaders()
        Description copied from interface: Message
        Return message headers for the message (never null but may be empty).
        Specified by:
        getHeaders in interface Message<T>
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object