Improve parameter naming for listener registration
This commit is contained in:
parent
ee688929fd
commit
d3abb0aca3
@ -258,12 +258,12 @@ public final class EventBus {
|
|||||||
*
|
*
|
||||||
* @param <E> the event type the listener listens for
|
* @param <E> the event type the listener listens for
|
||||||
* @param eventType the event type the listener listens for
|
* @param eventType the event type the listener listens for
|
||||||
* @param callback the callback that is invoked when an event occurs
|
* @param eventListener the callback that is invoked when an event occurs
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see #registerListener(Class, Consumer, boolean, int)
|
* @see #registerListener(Class, Consumer, boolean, int)
|
||||||
*/
|
*/
|
||||||
public <E> void registerListener(Class<E> eventType, Consumer<E> callback) {
|
public <E> void registerListener(Class<E> eventType, Consumer<E> eventListener) {
|
||||||
registerListener(eventType, callback, false, DEFAULT_PRIORITY);
|
registerListener(eventType, eventListener, false, DEFAULT_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -272,14 +272,14 @@ public final class EventBus {
|
|||||||
*
|
*
|
||||||
* @param <E> the event type the listener listens for
|
* @param <E> the event type the listener listens for
|
||||||
* @param eventType the event type the listener listens for
|
* @param eventType the event type the listener listens for
|
||||||
* @param callback the callback that is invoked when an event occurs
|
* @param eventListener the callback that is invoked when an event occurs
|
||||||
* @param polymorphic whether the listener is also invoked for subtypes of the event type
|
* @param polymorphic whether the listener is also invoked for subtypes of the event type
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see #registerListener(Class, Consumer, boolean, int)
|
* @see #registerListener(Class, Consumer, boolean, int)
|
||||||
*/
|
*/
|
||||||
public <E> void registerListener(Class<E> eventType, Consumer<E> callback,
|
public <E> void registerListener(Class<E> eventType, Consumer<E> eventListener,
|
||||||
boolean polymorphic) {
|
boolean polymorphic) {
|
||||||
registerListener(eventType, callback, polymorphic, DEFAULT_PRIORITY);
|
registerListener(eventType, eventListener, polymorphic, DEFAULT_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,13 +288,13 @@ public final class EventBus {
|
|||||||
*
|
*
|
||||||
* @param <E> the event type the listener listens for
|
* @param <E> the event type the listener listens for
|
||||||
* @param eventType the event type the listener listens for
|
* @param eventType the event type the listener listens for
|
||||||
* @param callback the callback that is invoked when an event occurs
|
* @param eventListener the callback that is invoked when an event occurs
|
||||||
* @param priority the priority to assign to the listener
|
* @param priority the priority to assign to the listener
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see #registerListener(Class, Consumer, boolean, int)
|
* @see #registerListener(Class, Consumer, boolean, int)
|
||||||
*/
|
*/
|
||||||
public <E> void registerListener(Class<E> eventType, Consumer<E> callback, int priority) {
|
public <E> void registerListener(Class<E> eventType, Consumer<E> eventListener, int priority) {
|
||||||
registerListener(eventType, callback, false, priority);
|
registerListener(eventType, eventListener, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,21 +302,22 @@ public final class EventBus {
|
|||||||
*
|
*
|
||||||
* @param <E> the event type the listener listens for
|
* @param <E> the event type the listener listens for
|
||||||
* @param eventType the event type the listener listens for
|
* @param eventType the event type the listener listens for
|
||||||
* @param callback the callback that is invoked when an event occurs
|
* @param eventListener the callback that is invoked when an event occurs
|
||||||
* @param polymorphic whether the listener is also invoked for subtypes of the event type
|
* @param polymorphic whether the listener is also invoked for subtypes of the event type
|
||||||
* @param priority the priority to assign to the listener
|
* @param priority the priority to assign to the listener
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public <E> void registerListener(Class<E> eventType, Consumer<E> callback, boolean polymorphic,
|
public <E> void registerListener(Class<E> eventType, Consumer<E> eventListener,
|
||||||
|
boolean polymorphic,
|
||||||
int priority) {
|
int priority) {
|
||||||
Objects.requireNonNull(callback);
|
Objects.requireNonNull(eventListener);
|
||||||
if (registeredListeners.contains(callback))
|
if (registeredListeners.contains(eventListener))
|
||||||
throw new EventBusException(callback + " already registered!");
|
throw new EventBusException(eventListener + " already registered!");
|
||||||
logger.log(Level.INFO, "Registering callback event listener {0}",
|
logger.log(Level.INFO, "Registering callback event listener {0}",
|
||||||
callback.getClass().getName());
|
eventListener.getClass().getName());
|
||||||
|
|
||||||
registeredListeners.add(callback);
|
registeredListeners.add(eventListener);
|
||||||
bindHandler(new CallbackEventHandler(eventType, callback, polymorphic, priority));
|
bindHandler(new CallbackEventHandler(eventType, eventListener, polymorphic, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,7 @@ public interface EventHandler {
|
|||||||
int getPriority();
|
int getPriority();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether this handler is polymorphic
|
* @return whether this handler also accepts subtypes of the event type
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see Polymorphic
|
* @see Polymorphic
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user