Record Class HandlerReference

java.lang.Object
java.lang.Record
civitas.celestis.event.HandlerReference
Record Components:
listener - The event listener instance
method - The event handler method

public record HandlerReference(@Nonnull Listener listener, @Nonnull Method method) extends Record
A reference to an event handler. Contains contextual information required to invoke the handler method, and retrieve its properties. While this is a transient reference object, its methods consist of core operations which alter the behavior of all event manager implementations. Exercise caution when modifying a member of this class.
See Also:
  • Constructor Details

    • HandlerReference

      public HandlerReference(@Nonnull Listener 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.
      Returns:
      The execution priority of this event handler
      See Also:
    • accepts

      public <E extends Handleable> boolean accepts(@Nonnull E event)
      Returns whether this handler accepts the provided event as its parameter.
      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) throws HandlerException
      Invokes the handler to process the event.
      Type Parameters:
      E - The type of event to handle
      Parameters:
      event - The event of which to handle
      Throws:
      HandlerException - When an exception occurs during the processing of the event
    • 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 Listener 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