@ -7851,6 +7851,58 @@ This new method will publish a new `ListUpdateEvent` for every `BlackListEvent`
@@ -7851,6 +7851,58 @@ This new method will publish a new `ListUpdateEvent` for every `BlackListEvent`
by the method above. If you need to publish several events, just return a `Collection` of
events instead.
[[context-functionality-events-generics]]
==== Generic Events
You may also use generics to further define the structure of your event. Consider an
`EntityCreatedEvent<T>` where `T` is the type of the actual entity that got created. You
can create the following listener definition to only receive `EntityCreatedEvent` for a
`Person`:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@EventListener
public void onPersonCreated(EntityCreatedEvent<Person> event) {
...
}
----
Due to type erasure, this will only work if the event that is fired resolves the generic
parameter(s) on which the event listener filters on (that is something like