org.springframework.messaging.support

## 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 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, Map<String,Object> headers)` Create a new message with the given payload and headers.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `MessageHeaders` | `getHeaders()` Return message headers for the message, never `null`.
    `T` | `getPayload()` Return the message payload.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 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,
                                Map<String,Object> headers)

      Create a new message with the given payload and headers.
      Parameters:
        `payload` - the message payload, never `null`
        `headers` - message headers

  - ### Method Detail

    - #### getHeaders

          public MessageHeaders getHeaders()

      Description copied from interface: `Message`
      Return message headers for the message, never `null`.
      Specified by:
        `getHeaders` in interface `Message<T>`

    - #### getPayload

          public T getPayload()

      Description copied from interface: `Message`
      Return the message payload.
      Specified by:
        `getPayload` in interface `Message<T>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`