Class DefaultRegisteredEventListener

java.lang.Object
eu.cloudnetservice.driver.event.DefaultRegisteredEventListener
All Implemented Interfaces:
RegisteredEventListener, Comparable<RegisteredEventListener>

final class DefaultRegisteredEventListener extends Object implements RegisteredEventListener
The default implementation of a registered event listener.
Since:
4.0
  • Field Details

    • LOGGER

      private static final eu.cloudnetservice.common.log.Logger LOGGER
    • instance

      private final Object instance
    • eventClass

      private final Class<?> eventClass
    • eventListener

      private final EventListener eventListener
    • methodName

      private final String methodName
    • methodArguments

      private final dev.derklaro.aerogel.Element[] methodArguments
    • methodAccessor

      private final dev.derklaro.reflexion.MethodAccessor<?> methodAccessor
    • injectionLayer

      private final InjectionLayer<?> injectionLayer
  • Constructor Details

    • DefaultRegisteredEventListener

      DefaultRegisteredEventListener(@NonNull @NonNull Object instance, @NonNull @NonNull Method targetMethod, @NonNull @NonNull EventListener eventListener, @NonNull @NonNull InjectionLayer<?> injectionLayer)
      Constructs a new default registered event listener instance.
      Parameters:
      instance - the instance all event listener methods should get called on.
      targetMethod - the method of the event listener.
      eventListener - the annotation used to identify the target method.
      injectionLayer - the injection layer to use when additional parameters are present on the target method.
      Throws:
      NullPointerException - if one of the given arguments is null.
  • Method Details

    • fireEvent

      public void fireEvent(@NonNull @NonNull Event event)
      Fires the event by invoking the underlying method with the given event. The event type is ensured to only be the same type the listener defined in the method. Event execution is not concurrent as per the event manager contract, therefore there is no need for locking before event execution.
      Specified by:
      fireEvent in interface RegisteredEventListener
      Parameters:
      event - the event to fire.
    • channel

      @NonNull public @NonNull String channel()
      Get the channel this event is listening to. Defaults to * meaning that the listener listens to all channels.
      Specified by:
      channel in interface RegisteredEventListener
      Returns:
      the channel this event is listening to.
    • order

      Get the priority defined in the @EventListener annotation on the original listener method.
      Specified by:
      order in interface RegisteredEventListener
      Returns:
      the priority of the underlying event listener.
    • instance

      @NonNull public @NonNull Object instance()
      Get the instance of the listener class used to register all listeners in it.
      Specified by:
      instance in interface RegisteredEventListener
      Returns:
      the instance of the listener class.
    • eventClass

      @NonNull public @NonNull Class<?> eventClass()
      Get the class type of the event the underlying listener is listening to.
      Specified by:
      eventClass in interface RegisteredEventListener
      Returns:
      the class type of the event this listener listens to.
    • eventListener

      @NonNull public @NonNull EventListener eventListener()
      Get the annotation used on the original listener method to identify it as a listener method.
      Specified by:
      eventListener in interface RegisteredEventListener
      Returns:
      the annotation used on the original listener method.