Package org.springframework.context

# Class PayloadApplicationEvent<T>

java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.context.PayloadApplicationEvent<T>

Type Parameters:
  `T` - the payload type of the event

All Implemented Interfaces:
  `Serializable`, `org.springframework.core.ResolvableTypeProvider`

public class PayloadApplicationEvent<T> extends ApplicationEvent implements org.springframework.core.ResolvableTypeProvider
An `ApplicationEvent` that carries an arbitrary payload.

Since:
  4.2
Author:
  Stephane Nicoll, Juergen Hoeller, Qimiao Chen
See Also:
  - `ApplicationEventPublisher.publishEvent(Object)`
  - `ApplicationListener.forPayload(Consumer)`
  - Serialized Form

## Field Summary

### Fields inherited from class java.util.EventObject

`source`

## Constructor Summary

Constructors
Constructor
Description
`PayloadApplicationEvent(Object source, T payload)`
Create a new PayloadApplicationEvent, using the instance to infer its type.
`PayloadApplicationEvent(Object source, T payload, org.springframework.core.ResolvableType payloadType)`
Create a new PayloadApplicationEvent based on the provided payload type.

## Method Summary

Modifier and Type
Method
Description
`T`
`getPayload()`
Return the payload of the event.
`org.springframework.core.ResolvableType`
`getResolvableType()`

### Methods inherited from class org.springframework.context.ApplicationEvent

`getTimestamp`

### Methods inherited from class java.util.EventObject

`getSource, toString`

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

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

## Constructor Details

### PayloadApplicationEvent

public PayloadApplicationEvent(Object source, T payload)
Create a new PayloadApplicationEvent, using the instance to infer its type.

Parameters:
  `source` - the object on which the event initially occurred (never `null`)
  `payload` - the payload object (never `null`)

### PayloadApplicationEvent

public PayloadApplicationEvent(Object source, T payload, @Nullable org.springframework.core.ResolvableType payloadType)
Create a new PayloadApplicationEvent based on the provided payload type.

Parameters:
  `source` - the object on which the event initially occurred (never `null`)
  `payload` - the payload object (never `null`)
  `payloadType` - the type object of payload object (can be `null`). Note that this is meant to indicate the payload type (for example, `String`), not the full event type (such as `PayloadApplicationEvent<&lt;String&gt;`).
Since:
  6.0

## Method Details

### getResolvableType

public org.springframework.core.ResolvableType getResolvableType()

Specified by:
  `getResolvableType` in interface `org.springframework.core.ResolvableTypeProvider`

### getPayload

public T getPayload()
Return the payload of the event.