Class SimpleEventRegistry<E>

  • Type Parameters:
    E - the base event type
    All Implemented Interfaces:
    EventRegistry<E>

    public class SimpleEventRegistry<E>
    extends Object
    implements EventRegistry<E>
    A simple implementation of an event registry.
    Since:
    1.0.0
    • Constructor Detail

      • SimpleEventRegistry

        public SimpleEventRegistry​(@NotNull
                                   @NotNull Class<E> type)
        Constructs a new SimpleEventRegistry.
        Parameters:
        type - the base event type
        Since:
        1.0.0
    • Method Detail

      • type

        @NotNull
        public @NotNull Class<E> type()
        Description copied from interface: EventRegistry
        Gets the base event type.

        This is represented by the E type parameter.

        Specified by:
        type in interface EventRegistry<E>
        Returns:
        the base event type
      • subscribe

        @NotNull
        public <T extends E> @NotNull EventSubscription<T> subscribe​(@NotNull
                                                                     @NotNull Class<T> event,
                                                                     @NotNull
                                                                     @NotNull EventConfig config,
                                                                     @NotNull
                                                                     @NotNull EventSubscriber<? super T> subscriber)
        Description copied from interface: EventRegistry
        Registers the given subscriber to receive events.
        Specified by:
        subscribe in interface EventRegistry<E>
        Type Parameters:
        T - the event type
        Parameters:
        event - the event type
        config - the event configuration
        subscriber - the subscriber
      • unsubscribeIf

        public void unsubscribeIf​(@NotNull
                                  @NotNull Predicate<EventSubscription<? super E>> predicate)
        Description copied from interface: EventRegistry
        Removes subscriptions matching predicate.
        Specified by:
        unsubscribeIf in interface EventRegistry<E>
        Parameters:
        predicate - the predicate used to determine which subscriptions to remove
      • subscriptions

        @NotNull
        public @NotNull List<EventSubscription<? super E>> subscriptions​(@NotNull
                                                                         @NotNull Class<? extends E> event)
        Description copied from interface: EventRegistry
        Gets an unmodifiable list containing all subscriptions currently registered for events of type event.
        Specified by:
        subscriptions in interface EventRegistry<E>
        Returns:
        a list of all subscriptions for events of type event