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 void |
getSuperClasses(java.util.Set<java.lang.Class<?>> classes,
java.lang.Class<?> clazz)
Get all super classes and interfaces of the given class.
|
static EventHandler |
newEventHandler(int priority)
Create a new
EventHandler instance with the given priority. |
static java.lang.String |
toString(java.lang.reflect.Method method)
Convert a method to a string.
|
static java.lang.String |
toString(java.lang.invoke.MethodHandle methodHandle)
Convert a method handle to a string.
|
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(java.lang.Class<?> owner, 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(java.lang.Class<?> owner, 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(java.lang.Class<?> owner,
EventHandler annotation,
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(java.lang.Class<?> owner,
EventHandler annotation,
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(EventHandler annotation, java.lang.reflect.Method method, 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(EventHandler annotation, java.lang.reflect.Field field, 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 accepted@Nonnull public static EventHandler newEventHandler(int priority)
EventHandler instance with the given priority.priority - The priority of the handlerEventHandler instancepublic static java.lang.String toString(java.lang.reflect.Method method)
method - The method to convertpublic static java.lang.String toString(java.lang.invoke.MethodHandle methodHandle)
methodHandle - The method to convertpublic static void getSuperClasses(java.util.Set<java.lang.Class<?>> classes,
java.lang.Class<?> clazz)
classes - The set to add the classes toclazz - The class to get the super classes from