パッケージ net.ririfa.beacon
インタフェース IEventHandler
public interface IEventHandler
Interface representing an event handler.
-
メソッドの概要
修飾子とタイプメソッド説明default List<IEventHandler>children()Returns the list of child event handlers.default booleanHandles events for this handler.voidPlease write a handler initialization code.default IEventHandlerparent()Returns the parent event handler.default voidUnregisters this event handler and all its children.
-
メソッドの詳細
-
initHandlers
void initHandlers()Please write a handler initialization code.For example:
@Override public void initHandlers() { handler(this, MyEvent.class, event -> { System.out.println("This is a handler for MyEvent: " + event.getMessage()); System.out.println("Thread: " + Thread.currentThread().getName()); return Unit.INSTANCE; }); handler(this, MyReturnableEvent.class, event -> { System.out.println("This is a handler for MyReturnableEvent: " + event.getMessage()); System.out.println("Thread: " + Thread.currentThread().getName()); return "Hello from returnable handler!"; }); } -
handleEvents
default boolean handleEvents()Handles events for this handler.- 戻り値:
- true if the events are handled successfully, false otherwise
-
parent
Returns the parent event handler.- 戻り値:
- the parent event handler, or null if there is no parent
-
children
Returns the list of child event handlers.- 戻り値:
- a list of child event handlers
-
unregister
default void unregister()Unregisters this event handler and all its children.
-