Allow event handlers with non-void return type

Also removed unnecessary files from the Event Bus Proc JAR and
configured GPG signing as well as deployment to Sonatype OSSRH.
This commit is contained in:
2021-02-17 08:56:42 +01:00
parent ff35e7f37d
commit 4a5b94a9b7
6 changed files with 59 additions and 32 deletions

View File

@ -6,17 +6,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.*;
/**
* Indicates that a method is an event handler. To be successfully used as such, the method has to
* comply with the following specifications:
* <ul>
* <li>Specifying an event type by either
* <ul>
* <li>Declaring one object parameter</li>
* <li>Defining the class of the event using the annotation value</li>
* </ul>
* </li>
* <li>Return type of {@code void}</li>
* </ul>
* Indicates that a method is an event handler.
* <p>
* To be successfully used as such, the method has to specify the event type by either declaring one
* parameter of that type or setting the annotation value to the corresponding class.
*
* @author Kai S. K. Engelbart
* @since 0.0.1

View File

@ -43,7 +43,7 @@ final class EventHandler implements Comparable<EventHandler> {
this.method = method;
useParameter = annotation.value() == USE_PARAMETER.class;
// Check for correct method signature and return type
// Check handler signature
if (method.getParameterCount() == 0 && useParameter)
throw new EventBusException(method + " does not define an event type!");
@ -53,9 +53,6 @@ final class EventHandler implements Comparable<EventHandler> {
if (method.getParameterCount() > 1)
throw new EventBusException(method + " defines more than one parameter!");
if (!method.getReturnType().equals(void.class))
throw new EventBusException(method + " does not have a return type of void!");
// Determine handler properties
eventType = useParameter ? method.getParameterTypes()[0] : annotation.value();
polymorphic = method.isAnnotationPresent(Polymorphic.class);