Record Class HandlerReference

java.lang.Object
java.lang.Record
me.wouterkistemaker.eventmanager.HandlerReference
Record Components:
listener - The event listener object
method - 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 Details

    • HandlerReference

      public HandlerReference(@Nonnull EventListener listener, @Nonnull Method method)
      Creates an instance of a HandlerReference record class.
      Parameters:
      listener - the value for the listener record component
      method - the value for the method record component
  • Method Details

    • priority

      @Nonnull public HandlerPriority priority()
      Returns the execution priority of this event handler. If not priority is specified, this will return HandlerPriority.MEDIUM.
      Returns:
      The execution priority of this event handler
    • accepts

      public <E extends Handleable> boolean accepts(@Nonnull E event)
      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

      public <E extends Handleable> void handle(@Nonnull E event)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • listener

      @Nonnull public EventListener listener()
      Returns the value of the listener record component.
      Returns:
      the value of the listener record component
    • method

      @Nonnull public Method method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component