Package me.wouterkistemaker.eventmanager
Record Class HandlerReference
java.lang.Object
java.lang.Record
me.wouterkistemaker.eventmanager.HandlerReference
- Record Components:
listener
- The event listener objectmethod
- The event handler method
public record HandlerReference(@Nonnull EventListener listener, @Nonnull Method method)
extends Record
A reference object to an event handler method. Handler references are transient
objects used internally by the event manager.
- Since:
- 1.1
- Author:
- themrsung
-
Constructor Summary
ConstructorsConstructorDescriptionHandlerReference
(EventListener listener, Method method) Creates an instance of aHandlerReference
record class. -
Method Summary
Modifier and TypeMethodDescription<E extends Handleable>
booleanaccepts
(E event) Returns whether this event handler accepts the provided event.final boolean
Indicates whether some other object is "equal to" this one.<E extends Handleable>
voidhandle
(E event) Called to handle the event.final int
hashCode()
Returns a hash code value for this object.listener()
Returns the value of thelistener
record component.method()
Returns the value of themethod
record component.priority()
Returns the execution priority of this event handler.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
priority
Returns the execution priority of this event handler. If not priority is specified, this will returnHandlerPriority.MEDIUM
.- Returns:
- The execution priority of this event handler
-
accepts
Returns whether this event handler accepts the provided event.- Type Parameters:
E
- The type of event to check for acceptance- Parameters:
event
- The event of which to check for acceptance.- Returns:
true
if this event handler accepts the event
-
handle
Called to handle the event. This handles the invocation of the event handler.- Type Parameters:
E
- The type of event to handle- Parameters:
event
- The event of which to handle
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
listener
Returns the value of thelistener
record component.- Returns:
- the value of the
listener
record component
-
method
Returns the value of themethod
record component.- Returns:
- the value of the
method
record component
-