public class EventUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
EventUtils.FieldHandler
A wrapper class for an event handler field with it's
EventHandler annotation. |
static class |
EventUtils.MethodHandler
A wrapper class for an event handler method with it's
EventHandler annotation. |
| Constructor and Description |
|---|
EventUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?>[] |
getEvents(EventHandler annotation,
java.lang.reflect.Field field,
java.util.function.Predicate<java.lang.Class<?>> accept)
Get all events handled by the given field.
|
static java.lang.Class<?>[] |
getEvents(EventHandler annotation,
java.lang.reflect.Method method,
java.util.function.Predicate<java.lang.Class<?>> accept)
Get all events handled by the given method.
|
static java.util.List<EventUtils.FieldHandler> |
getFields(java.lang.Class<?> owner,
java.util.function.Predicate<java.lang.reflect.Field> accept,
boolean registerSuperHandler)
Get all fields of the given class which are annotated with
EventHandler. |
static java.util.List<EventUtils.MethodHandler> |
getMethods(java.lang.Class<?> owner,
java.util.function.Predicate<java.lang.reflect.Method> accept,
boolean registerSuperHandler)
Get all methods of the given class which are annotated with
EventHandler. |
static EventHandler |
newEventHandler(int priority)
Create a new
EventHandler instance with the given priority. |
static <T extends java.lang.Throwable> |
sneak(java.lang.Throwable t)
Sneaky throw the given exception without declaring it.
|
static void |
verify(java.lang.Class<?> owner,
EventHandler annotation,
java.lang.reflect.Field field)
Check if the given field is a valid event handler field.
|
static void |
verify(java.lang.Class<?> owner,
EventHandler annotation,
java.lang.reflect.Method method)
Check if the given method is a valid event handler method.
|
@Nonnull public static java.util.List<EventUtils.MethodHandler> getMethods(@Nonnull java.lang.Class<?> owner, @Nonnull java.util.function.Predicate<java.lang.reflect.Method> accept, boolean registerSuperHandler)
EventHandler.owner - The class to get the methods fromaccept - If the method should be acceptedregisterSuperHandler - If the super methods should be registered@Nonnull public static java.util.List<EventUtils.FieldHandler> getFields(@Nonnull java.lang.Class<?> owner, @Nonnull java.util.function.Predicate<java.lang.reflect.Field> accept, boolean registerSuperHandler)
EventHandler.owner - The class to get the fields fromaccept - If the field should be acceptedregisterSuperHandler - If the super fields should be registeredpublic static void verify(@Nonnull
java.lang.Class<?> owner,
@Nonnull
EventHandler annotation,
@Nonnull
java.lang.reflect.Method method)
owner - The owner of the methodannotation - The EventHandler annotation of the methodmethod - The method to checkjava.lang.IllegalStateException - If the method is not validpublic static void verify(@Nonnull
java.lang.Class<?> owner,
@Nonnull
EventHandler annotation,
@Nonnull
java.lang.reflect.Field field)
owner - The owner of the fieldannotation - The EventHandler annotation of the fieldfield - The field to check@Nonnull
public static java.lang.Class<?>[] getEvents(@Nonnull
EventHandler annotation,
@Nonnull
java.lang.reflect.Method method,
@Nonnull
java.util.function.Predicate<java.lang.Class<?>> accept)
annotation - The EventHandler annotation of the methodmethod - The method to get the events fromaccept - If the event should be accepted@Nonnull
public static java.lang.Class<?>[] getEvents(@Nonnull
EventHandler annotation,
@Nonnull
java.lang.reflect.Field field,
@Nonnull
java.util.function.Predicate<java.lang.Class<?>> accept)
annotation - The EventHandler annotation of the fieldfield - The field to get the events fromaccept - If the event should be acceptedpublic static <T extends java.lang.Throwable> void sneak(@Nonnull
java.lang.Throwable t)
throws T extends java.lang.Throwable
T - The type to confuse the compilert - The exception to throwT - The given exceptionT extends java.lang.Throwable@Nonnull public static EventHandler newEventHandler(int priority)
EventHandler instance with the given priority.priority - The priority of the handlerEventHandler instance