Top Description Fields Constructors Methods
org.springframework.context

public Class PayloadApplicationEvent<T>

extends ApplicationEvent
implements ResolvableTypeProvider
Class Inheritance
All Implemented Interfaces
org.springframework.core.ResolvableTypeProvider
Annotations
@SuppressWarnings:serial
Type Parameters
<T>
the payload type of the event
Imports
java.util.function.Consumer, org.springframework.core.ResolvableType, .ResolvableTypeProvider, org.springframework.lang.Nullable, org.springframework.util.Assert

An ApplicationEvent that carries an arbitrary payload.
Authors
Stephane Nicoll, Juergen Hoeller, Qimiao Chen
Since
4.2
See Also
ApplicationEventPublisher#publishEvent(Object), ApplicationListener#forPayload(Consumer)

Field Summary

Modifier and TypeField and Description
private final T
private final ResolvableType

Constructor Summary

AccessConstructor and Description
public
PayloadApplicationEvent(Object
the object on which the event initially occurred (never null)
source
,
T
the payload object (never null)
payload
)

Create a new PayloadApplicationEvent, using the instance to infer its type.

public
PayloadApplicationEvent(Object
the object on which the event initially occurred (never null)
source
,
T
the payload object (never null)
payload
,
ResolvableType
the type object of payload object (can be null). Note that this is meant to indicate the payload type (e.g. String), not the full event type (such as PayloadApplicationEvent<<String>).
payloadType
)

Create a new PayloadApplicationEvent based on the provided payload type.

Method Summary

Modifier and TypeMethod and Description
public T
getPayload()

Return the payload of the event.

public ResolvableType
getResolvableType()

Implements org.springframework.core.ResolvableTypeProvider.getResolvableType.

Return the ResolvableType describing this instance (or null if some sort of default should be applied instead).
Inherited from org.springframework.context.ApplicationEvent:
getTimestamp

Field Detail

payloadback to summary
private final T payload
payloadTypeback to summary
private final ResolvableType payloadType

Constructor Detail

PayloadApplicationEventback to summary
public PayloadApplicationEvent(Object source, T payload)

Create a new PayloadApplicationEvent, using the instance to infer its type.

Parameters
source:Object

the object on which the event initially occurred (never null)

payload:T

the payload object (never null)

PayloadApplicationEventback to summary
public PayloadApplicationEvent(Object source, T payload, ResolvableType payloadType)

Create a new PayloadApplicationEvent based on the provided payload type.

Parameters
source:Object

the object on which the event initially occurred (never null)

payload:T

the payload object (never null)

payloadType:ResolvableType

the type object of payload object (can be null). Note that this is meant to indicate the payload type (e.g. String), not the full event type (such as PayloadApplicationEvent<<String>).

Since
6.0

Method Detail

getPayloadback to summary
public T getPayload()

Return the payload of the event.

getResolvableTypeback to summary
public ResolvableType getResolvableType()

Implements org.springframework.core.ResolvableTypeProvider.getResolvableType.

Doc from org.springframework.core.ResolvableTypeProvider.getResolvableType.

Return the ResolvableType describing this instance (or null if some sort of default should be applied instead).

Annotations
@Override