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:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionPayloadApplicationEvent
(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 TypeMethodDescriptionReturn the payload of the event.org.springframework.core.ResolvableType
Methods inherited from class org.springframework.context.ApplicationEvent
getTimestamp
Methods inherited from class java.util.EventObject
getSource, toString
-
Constructor Details
-
PayloadApplicationEvent
Create a new PayloadApplicationEvent, using the instance to infer its type.- Parameters:
source
- the object on which the event initially occurred (nevernull
)payload
- the payload object (nevernull
)
-
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 (nevernull
)payload
- the payload object (nevernull
)payloadType
- the type object of payload object (can benull
). Note that this is meant to indicate the payload type (e.g.String
), not the full event type (such asPayloadApplicationEvent<<String>
).- Since:
- 6.0
-
-
Method Details
-
getResolvableType
public org.springframework.core.ResolvableType getResolvableType()- Specified by:
getResolvableType
in interfaceorg.springframework.core.ResolvableTypeProvider
-
getPayload
Return the payload of the event.
-