mirror of
https://github.com/zaaarf/geb.git
synced 2024-11-21 23:04:52 +01:00
feat: generic IEventDispatcher
This commit is contained in:
parent
81968f1c16
commit
15fd1373ce
2 changed files with 6 additions and 4 deletions
|
@ -7,19 +7,20 @@ import java.util.Set;
|
|||
* The interface that the generated dispatchers will all use.
|
||||
* This interface isn't really meant to be used by humans, but it should work if your
|
||||
* use case requires it.
|
||||
* @param <T> the event this is for
|
||||
* @since 0.1.1
|
||||
*/
|
||||
public interface IEventDispatcher {
|
||||
public interface IEventDispatcher<T extends IEvent> {
|
||||
/**
|
||||
* Calls all listeners for the given event.
|
||||
* @param event the event to call
|
||||
* @param listeners a map mapping each {@link IListener} class to its instances
|
||||
* @return the value {@link IBus#handleEvent(IEvent)} will return for this
|
||||
*/
|
||||
boolean callListeners(IEvent event, Map<Class<? extends IListener>, Set<IListener>> listeners);
|
||||
boolean callListeners(T event, Map<Class<? extends IListener>, Set<IListener>> listeners);
|
||||
|
||||
/**
|
||||
* @return the {@link Class} representing the event this dispatcher works with
|
||||
*/
|
||||
Class<? extends IEvent> eventType();
|
||||
Class<T> eventType();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks the method as a listener. Its parent must implement the {@link IListener} interface
|
||||
* Marks the method as a listener.
|
||||
* If the method is not static, its parent must implement the {@link IListener} interface
|
||||
* and be registered an at least one GEB instance with {@link IBus#registerListener(IListener)}.
|
||||
* The annotated method should only take a single input value, an instance of {@link IEvent} or
|
||||
* {@link IEventCancelable}.
|
||||
|
|
Loading…
Reference in a new issue