Class Event.Impl<L>

java.lang.Object
com.thecsdev.common.event.Event.Impl<L>
Type Parameters:
L - Event listener type.
All Implemented Interfaces:
Event<L>
Enclosing interface:
Event<L>

public static final class Event.Impl<L> extends Object implements Event<L>
Main Event implementation.
  • Constructor Details

  • Method Details

    • invoker

      public final @NonNull L invoker()
      Description copied from interface: Event
      Returns the invoker of this Event, which is used to fire this Event and invoke all registered listeners.
      Specified by:
      invoker in interface Event<L>
    • addListener

      public final boolean addListener(@NonNull L listener) throws NullPointerException
      Description copied from interface: Event
      Adds a listener to this Event, that is to be invoked when this Event is fired.
      Specified by:
      addListener in interface Event<L>
      Parameters:
      listener - The listener that will be invoked when this Event is fired.
      Returns:
      false if the listener was already registered, true otherwise.
      Throws:
      NullPointerException - If the argument is null.
    • removeListener

      public final boolean removeListener(@NonNull L listener) throws NullPointerException
      Description copied from interface: Event
      Removes a listener from this Event, so that it will no longer be invoked when this Event is fired.
      Specified by:
      removeListener in interface Event<L>
      Parameters:
      listener - The listener to be removed.
      Returns:
      true if the listener was registered before removal, false otherwise.
      Throws:
      NullPointerException - If the argument is null.
    • clearListeners

      public final void clearListeners()
      Description copied from interface: Event
      Removes all listeners from this Event, so that no listeners will be invoked when this Event is fired.
      Specified by:
      clearListeners in interface Event<L>
    • containsListener

      public final boolean containsListener(@NonNull L listener) throws NullPointerException
      Description copied from interface: Event
      Checks if a listener is added to this Event.
      Specified by:
      containsListener in interface Event<L>
      Parameters:
      listener - The listener to check for.
      Returns:
      true if the listener is added, false otherwise.
      Throws:
      NullPointerException - If the argument is null.