2021-02-09 09:52:26 +01:00
|
|
|
package dev.kske.eventbus.core;
|
2020-09-02 16:15:31 +02:00
|
|
|
|
|
|
|
import static java.lang.annotation.ElementType.METHOD;
|
|
|
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
|
|
|
|
|
|
import java.lang.annotation.*;
|
|
|
|
|
|
|
|
/**
|
2021-02-17 08:56:42 +01:00
|
|
|
* 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.
|
2020-09-02 16:15:31 +02:00
|
|
|
*
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since 0.0.1
|
2021-02-15 10:55:30 +01:00
|
|
|
* @see Polymorphic
|
2021-02-15 12:06:33 +01:00
|
|
|
* @see Priority
|
2020-09-02 16:15:31 +02:00
|
|
|
*/
|
|
|
|
@Documented
|
|
|
|
@Retention(RUNTIME)
|
|
|
|
@Target(METHOD)
|
|
|
|
public @interface Event {
|
|
|
|
|
2020-09-08 19:47:21 +02:00
|
|
|
/**
|
2021-11-02 19:33:18 +01:00
|
|
|
* Defines the event type the handler listens for. If this value is set, the handler is not
|
2020-09-08 19:47:21 +02:00
|
|
|
* allowed to declare parameters.
|
|
|
|
* <p>
|
|
|
|
* This is useful when the event handler does not utilize the event instance.
|
|
|
|
*
|
2020-09-20 14:05:35 +02:00
|
|
|
* @return the event type accepted by the handler
|
2021-02-15 13:42:20 +01:00
|
|
|
* @since 1.0.0
|
2020-09-08 19:47:21 +02:00
|
|
|
*/
|
2021-02-15 14:43:34 +01:00
|
|
|
Class<?> value() default USE_PARAMETER.class;
|
2020-09-08 19:47:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signifies that the event type the handler listens to is determined by the type of its only
|
|
|
|
* parameter.
|
|
|
|
*
|
|
|
|
* @since 0.0.3
|
|
|
|
*/
|
2021-02-15 14:43:34 +01:00
|
|
|
static final class USE_PARAMETER {}
|
2020-09-02 16:15:31 +02:00
|
|
|
}
|