Use void.class to determine how the event handler type is defined
Some checks failed
zdm/event-bus/pipeline/head There was a failure building this commit

The dummy class USE_PARAMETER was necessary when the IEvent interface
still existed, as void.class could not be used as a Class<? extends
IEvent>. As no explicit reference to USE_PARAMETER should be present
anywhere, a proper deprecation would've made little sense.
This commit is contained in:
2022-01-12 19:41:53 +01:00
parent 999a172e72
commit 36ed55fd71
3 changed files with 7 additions and 24 deletions

View File

@ -30,13 +30,5 @@ public @interface Event {
* @return the event type accepted by the handler
* @since 1.0.0
*/
Class<?> value() default USE_PARAMETER.class;
/**
* Signifies that the event type the handler listens to is determined by the type of its only
* parameter.
*
* @since 0.0.3
*/
static final class USE_PARAMETER {}
Class<?> value() default void.class;
}

View File

@ -3,7 +3,6 @@ package dev.kske.eventbus.core.handler;
import java.lang.reflect.*;
import dev.kske.eventbus.core.*;
import dev.kske.eventbus.core.Event.USE_PARAMETER;
/**
* An event handler wrapping a method annotated with {@link Event} and executing it using
@ -37,7 +36,7 @@ public final class ReflectiveEventHandler implements EventHandler {
boolean defPolymorphism, int defPriority) throws EventBusException {
this.listener = listener;
this.method = method;
useParameter = annotation.value() == USE_PARAMETER.class;
useParameter = annotation.value() == void.class;
// Check handler signature
if (method.getParameterCount() == 0 && useParameter)