Interface EventRegistry<E>

  • Type Parameters:
    E - the base event type
    All Known Implementing Classes:
    SimpleEventRegistry

    public interface EventRegistry<E>
    An event registry.
    Since:
    1.0.0
    • Method Detail

      • type

        @NotNull
        @NotNull Class<E> type()
        Gets the base event type.

        This is represented by the E type parameter.

        Returns:
        the base event type
        Since:
        1.0.0
      • subscribed

        default boolean subscribed​(@NotNull
                                   @NotNull Class<? extends E> event)
        Determines whether the specified event has subscribers.
        Parameters:
        event - the event type
        Returns:
        whether the specified event has subscribers
        Since:
        1.0.0
      • subscribe

        @NotNull
        default <T extends E> @NotNull EventSubscription<T> subscribe​(@NotNull
                                                                      @NotNull Class<T> event,
                                                                      @NotNull
                                                                      @NotNull EventSubscriber<? super T> subscriber)
        Registers the given subscriber to receive events, using the default configuration.
        Type Parameters:
        T - the event type
        Parameters:
        event - the event type
        subscriber - the subscriber
        Since:
        1.0.0
      • subscribe

        @NotNull
        <T extends E> @NotNull EventSubscription<T> subscribe​(@NotNull
                                                              @NotNull Class<T> event,
                                                              @NotNull
                                                              @NotNull EventConfig config,
                                                              @NotNull
                                                              @NotNull EventSubscriber<? super T> subscriber)
        Registers the given subscriber to receive events.
        Type Parameters:
        T - the event type
        Parameters:
        event - the event type
        config - the event configuration
        subscriber - the subscriber
        Since:
        1.0.0
      • unsubscribeIf

        void unsubscribeIf​(@NotNull
                           @NotNull Predicate<EventSubscription<? super E>> predicate)
        Removes subscriptions matching predicate.
        Parameters:
        predicate - the predicate used to determine which subscriptions to remove
        Since:
        1.0.0
      • subscriptions

        @NotNull
        @NotNull List<EventSubscription<? super E>> subscriptions​(@NotNull
                                                                  @NotNull Class<? extends E> event)
        Gets an unmodifiable list containing all subscriptions currently registered for events of type event.
        Returns:
        a list of all subscriptions for events of type event
        Since:
        1.0.0