Class OwnedEventBusImpl<O,​E,​S extends OwnedSubscriber<O,​? extends E>>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected static <T extends U,​U>
      java.util.Set<T>
      castGenericSet​(java.util.Set<U> o)  
      protected <T extends Subscriber<U>,​U>
      java.util.Set<T>
      eventSubscribers​(java.lang.Class<U> eventType)  
      protected <T extends E>
      void
      findSubscriptions​(@NonNull java.lang.Object listener, TriConsumer<java.lang.Class<T>,​Subscribe,​java.util.function.BiConsumer<java.lang.Object,​T>> consumer)  
      FireResult fire​(@NonNull E event)
      Fires the given event and log all exceptions that occur while executing this event.
      FireResult fireSilently​(@NonNull E event)
      Fires the given event silently.
      protected abstract <T extends E,​B extends OwnedSubscriber<O,​T>>
      B
      makeSubscription​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler, @NonNull PostOrder postOrder)  
      protected abstract <L,​T extends E,​B extends OwnedSubscriber<O,​T>>
      B
      makeSubscription​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull Subscribe subscribe, @NonNull L listener, @NonNull java.util.function.BiConsumer<L,​T> handler)  
      void register​(@NonNull O owner, @NonNull java.lang.Object listener)
      Registers events for the given listener.
      protected <T extends E>
      void
      register​(java.lang.Class<T> eventClass, S subscriber)  
      protected java.util.List<S> sortedSubscribers​(java.lang.Class<?> eventClass)  
      <T extends E,​U extends OwnedSubscriber<O,​T>>
      @NonNull U
      subscribe​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler)
      Subscribes to the given event see Subscriber.
      <T extends E,​U extends OwnedSubscriber<O,​T>>
      @NonNull U
      subscribe​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler, @NonNull PostOrder postOrder)
      Subscribes to the given event see Subscriber.
      <T extends E>
      @NonNull java.util.Set<? extends OwnedSubscriber<O,​T>>
      subscribers​(@NonNull java.lang.Class<T> eventClass)
      Gets the subscriptions for the given event class.
      void unregisterAll​(@NonNull O owner)
      Unregisters all events from a given owner.
      void unsubscribe​(@NonNull S subscription)
      Unsubscribes the given Subscriber.
      protected void unsubscribeAll()  
      protected void unsubscribeMany​(java.lang.Iterable<S> subscriptions)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OwnedEventBusImpl

        public OwnedEventBusImpl()
    • Method Detail

      • makeSubscription

        protected abstract <L,​T extends E,​B extends OwnedSubscriber<O,​T>> B makeSubscription​(@NonNull O owner,
                                                                                                               @NonNull java.lang.Class<T> eventClass,
                                                                                                               @NonNull Subscribe subscribe,
                                                                                                               @NonNull L listener,
                                                                                                               @NonNull java.util.function.BiConsumer<L,​T> handler)
      • makeSubscription

        protected abstract <T extends E,​B extends OwnedSubscriber<O,​T>> B makeSubscription​(@NonNull O owner,
                                                                                                       @NonNull java.lang.Class<T> eventClass,
                                                                                                       @NonNull java.util.function.Consumer<T> handler,
                                                                                                       @NonNull PostOrder postOrder)
      • subscribe

        public <T extends E,​U extends OwnedSubscriber<O,​T>> @NonNull U subscribe​(@NonNull O owner,
                                                                                             @NonNull java.lang.Class<T> eventClass,
                                                                                             @NonNull java.util.function.Consumer<T> handler)
        Description copied from interface: OwnedEventBus
        Subscribes to the given event see Subscriber.

        The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.

        Specified by:
        subscribe in interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>
        Type Parameters:
        T - the event class
        Parameters:
        owner - the extension to subscribe the event to
        eventClass - the class of the event
        handler - the consumer for handling the event
        Returns:
        the event subscription
      • subscribe

        public <T extends E,​U extends OwnedSubscriber<O,​T>> @NonNull U subscribe​(@NonNull O owner,
                                                                                             @NonNull java.lang.Class<T> eventClass,
                                                                                             @NonNull java.util.function.Consumer<T> handler,
                                                                                             @NonNull PostOrder postOrder)
        Description copied from interface: OwnedEventBus
        Subscribes to the given event see Subscriber.

        The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.

        Specified by:
        subscribe in interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>
        Type Parameters:
        T - the event class
        Parameters:
        owner - the extension to subscribe the event to
        eventClass - the class of the event
        handler - the consumer for handling the event
        postOrder - the order of the subscriber
        Returns:
        the event subscription
      • register

        public void register​(@NonNull O owner,
                             @NonNull java.lang.Object listener)
        Description copied from interface: OwnedEventBus
        Registers events for the given listener.
        Specified by:
        register in interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>
        Parameters:
        owner - the extension registering the event
        listener - the listener
      • unregisterAll

        public void unregisterAll​(@NonNull O owner)
        Description copied from interface: OwnedEventBus
        Unregisters all events from a given owner.
        Specified by:
        unregisterAll in interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>
        Parameters:
        owner - the extension
      • subscribers

        public <T extends E> @NonNull java.util.Set<? extends OwnedSubscriber<O,​T>> subscribers​(@NonNull java.lang.Class<T> eventClass)
        Description copied from interface: BaseBus
        Gets the subscriptions for the given event class.
        Specified by:
        subscribers in interface BaseBus<O,​E>
        Specified by:
        subscribers in interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>
        Type Parameters:
        T - the value
        Parameters:
        eventClass - the event class
        Returns:
        the subscriptions for the event class
      • register

        protected <T extends E> void register​(java.lang.Class<T> eventClass,
                                              S subscriber)
      • findSubscriptions

        protected <T extends E> void findSubscriptions​(@NonNull java.lang.Object listener,
                                                       TriConsumer<java.lang.Class<T>,​Subscribe,​java.util.function.BiConsumer<java.lang.Object,​T>> consumer)
      • unsubscribe

        public void unsubscribe​(@NonNull S subscription)
        Description copied from interface: BaseBus
        Unsubscribes the given Subscriber.
        Specified by:
        unsubscribe in interface BaseBus<E,​S extends Subscriber<? extends E>>
        Parameters:
        subscription - the event subscription
      • unsubscribeMany

        protected void unsubscribeMany​(java.lang.Iterable<S> subscriptions)
      • unsubscribeAll

        protected void unsubscribeAll()
      • fire

        public FireResult fire​(@NonNull E event)
        Description copied from interface: BaseBus
        Fires the given event and log all exceptions that occur while executing this event.
        Specified by:
        fire in interface BaseBus<E,​S extends Subscriber<? extends E>>
        Parameters:
        event - the event to fire
      • fireSilently

        public FireResult fireSilently​(@NonNull E event)
        Description copied from interface: BaseBus
        Fires the given event silently.
        Specified by:
        fireSilently in interface BaseBus<E,​S extends Subscriber<? extends E>>
        Parameters:
        event - the event to fire
        Returns:
        the result of firing the given event
      • sortedSubscribers

        protected java.util.List<S> sortedSubscribers​(java.lang.Class<?> eventClass)
      • eventSubscribers

        protected <T extends Subscriber<U>,​U> java.util.Set<T> eventSubscribers​(java.lang.Class<U> eventType)
      • castGenericSet

        protected static <T extends U,​U> java.util.Set<T> castGenericSet​(java.util.Set<U> o)