@ParametersAreNonnullByDefault
public class LambdaManager
extends java.lang.Object
| Constructor and Description |
|---|
LambdaManager(java.util.Map<java.lang.Class<?>,java.util.List<AHandler>> handlers,
java.util.function.Supplier<java.util.List<AHandler>> listSupplier,
IGenerator generator)
Deprecated.
|
LambdaManager(java.util.function.Supplier<java.util.Map> mapSupplier,
java.util.function.Supplier<java.util.List<AHandler>> listSupplier,
IGenerator generator) |
| Modifier and Type | Method and Description |
|---|---|
static LambdaManager |
basic(IGenerator generator)
|
<T> T |
call(T event)
Call all handlers for the given event.
|
<T> T |
callParents(T event)
Call all handlers for the given event and all parent classes of the event (including interfaces).
|
void |
register(java.lang.Class<?> owner)
Register all static event handlers in the given class.
|
void |
register(java.lang.Class<?> event,
java.lang.Class<?> owner)
Register all static event handlers for the given event in the given class.
|
void |
register(java.lang.Class<?> event,
java.lang.Object owner)
Register all non-static event handlers for the given event in the given object's class.
|
void |
register(java.util.function.Consumer<?> consumer,
java.lang.Class<?>... events)
Register a
Consumer as an event handler for the given events. |
void |
register(java.util.function.Consumer<?> consumer,
int priority,
java.lang.Class<?>... events)
Register a
Consumer as an event handler for the given events with the given priority. |
void |
register(java.lang.Object owner)
Register all non-static event handlers in the given object's class.
|
void |
register(java.lang.Runnable runnable,
java.lang.Class<?>... events)
Register a
Runnable as an event handler for the given events. |
void |
register(java.lang.Runnable runnable,
int priority,
java.lang.Class<?>... events)
Register a
Runnable as an event handler for the given events with the given priority. |
void |
registerSuper(java.lang.Class<?> event,
java.lang.Object owner)
Register all non-static event handlers for the given event in the given object's class and all its super classes.
|
void |
registerSuper(java.lang.Object owner)
Register all non-static event handlers for the given object's class and all its super classes.
|
void |
setAlwaysCallParents(boolean alwaysCallParents)
Always call all event handlers for parent classes of the event (including interfaces).
|
void |
setExceptionHandler(IExceptionHandler exceptionHandler)
Set the
IExceptionHandler which is used to handle thrown exceptions in event handlers. |
void |
setRegisterSuperHandler(boolean registerSuperHandler)
Register all event handlers from super classes.
|
static LambdaManager |
threadSafe(IGenerator generator)
|
java.lang.String |
toString()
Generate a debug output of all registered events and handlers.
|
void |
unregister(java.lang.Class<?> owner)
Unregister all static event handlers from the given class.
|
void |
unregister(java.lang.Class<?> event,
java.lang.Class<?> owner)
Unregister all static event handlers for the given event from the given class.
|
void |
unregister(java.lang.Class<?> event,
java.lang.Object owner)
Unregister all non-static event handlers for the given event from the given object's class.
|
void |
unregister(java.util.function.Consumer<?> consumer)
Unregister a
Consumer from all events. |
void |
unregister(java.util.function.Consumer<?> consumer,
java.lang.Class<?>... events)
Unregister a
Consumer from the given events. |
void |
unregister(java.lang.Object owner)
Unregister all non-static event handlers from the given object's class.
|
void |
unregister(java.lang.Runnable runnable)
Unregister a
Runnable from all events. |
void |
unregister(java.lang.Runnable runnable,
java.lang.Class<?>... events)
Unregister a
Runnable from the given events. |
@Deprecated public LambdaManager(java.util.Map<java.lang.Class<?>,java.util.List<AHandler>> handlers, java.util.function.Supplier<java.util.List<AHandler>> listSupplier, IGenerator generator)
LambdaManager(Supplier, Supplier, IGenerator).public LambdaManager(java.util.function.Supplier<java.util.Map> mapSupplier,
java.util.function.Supplier<java.util.List<AHandler>> listSupplier,
IGenerator generator)
mapSupplier - The supplier for the maps used to store the event to handler mappingslistSupplier - The supplier for the list used to store the handlers for an eventgenerator - The IGenerator implementation which should be usedpublic static LambdaManager basic(IGenerator generator)
LambdaManager instance using a HashMap and ArrayList.generator - The IGenerator implementation which should be usedLambdaManager instancepublic static LambdaManager threadSafe(IGenerator generator)
LambdaManager instance using a ConcurrentHashMap and CopyOnWriteArrayList.generator - The IGenerator implementation which should be usedLambdaManager instancepublic void setExceptionHandler(IExceptionHandler exceptionHandler)
IExceptionHandler which is used to handle thrown exceptions in event handlers.exceptionHandler - The IExceptionHandler which should be used to handle exceptionspublic void setRegisterSuperHandler(boolean registerSuperHandler)
registerSuperHandler - If super classes should be scanned for event handlerspublic void setAlwaysCallParents(boolean alwaysCallParents)
call(Object) to callParents(Object).alwaysCallParents - If all event handlers for parent classes should be called@Nonnull public <T> T call(T event)
T - The event typeevent - The event instance@Nonnull public <T> T callParents(T event)
RuntimeException -> Exception -> Throwable -> Serializable -> ObjectT - The event typeevent - The event instancepublic void register(java.lang.Class<?> owner)
owner - The class which should be scannedpublic void register(@Nullable
java.lang.Class<?> event,
java.lang.Class<?> owner)
event - The event classowner - The class which should be scannedpublic void register(java.lang.Object owner)
owner - The object which should be scannedpublic void register(@Nullable
java.lang.Class<?> event,
java.lang.Object owner)
event - The event classowner - The object which should be scannedpublic void registerSuper(java.lang.Object owner)
owner - The object which should be scannedpublic void registerSuper(@Nullable
java.lang.Class<?> event,
java.lang.Object owner)
event - The event classowner - The object which should be scannedpublic void register(java.lang.Runnable runnable,
java.lang.Class<?>... events)
Runnable as an event handler for the given events.runnable - The Runnable which should be registeredevents - The events for which the Runnable should be registeredpublic void register(java.lang.Runnable runnable,
int priority,
java.lang.Class<?>... events)
Runnable as an event handler for the given events with the given priority.runnable - The Runnable which should be registeredpriority - The priority of the Runnableevents - The events for which the Runnable should be registeredpublic void register(java.util.function.Consumer<?> consumer,
java.lang.Class<?>... events)
Consumer as an event handler for the given events.Consumer will be called with the event instance as parameter.
When using wrong type args this will result in a ClassCastException.consumer - The Consumer which should be registeredevents - The events for which the Consumer should be registeredpublic void register(java.util.function.Consumer<?> consumer,
int priority,
java.lang.Class<?>... events)
Consumer as an event handler for the given events with the given priority.Consumer will be called with the event instance as parameter.
When using wrong type args this will result in a ClassCastException.consumer - The Consumer which should be registeredpriority - The priority of the Consumerevents - The events for which the Consumer should be registeredpublic void unregister(java.lang.Class<?> owner)
owner - The class from which the static event handlers should be unregisteredpublic void unregister(java.lang.Class<?> event,
java.lang.Class<?> owner)
event - The event classowner - The class from which the static event handlers should be unregisteredpublic void unregister(java.lang.Object owner)
owner - The object from which the non-static event handlers should be unregisteredpublic void unregister(java.lang.Class<?> event,
java.lang.Object owner)
event - The event classowner - The object from which the non-static event handlers should be unregisteredpublic void unregister(java.lang.Runnable runnable)
Runnable from all events.runnable - The Runnable to unregisterpublic void unregister(java.lang.Runnable runnable,
java.lang.Class<?>... events)
Runnable from the given events.runnable - The Runnable to unregisterevents - The events from which the Runnable should be unregisteredpublic void unregister(java.util.function.Consumer<?> consumer)
Consumer from all events.consumer - The Consumer to unregisterpublic void unregister(java.util.function.Consumer<?> consumer,
java.lang.Class<?>... events)
Consumer from the given events.consumer - The Consumer to unregisterevents - The events from which the Consumer should be unregisteredpublic java.lang.String toString()
toString in class java.lang.Object