Class MultiHandlerManager<H>

  • Type Parameters:
    H - the handler type
    Direct Known Subclasses:
    OnScheduleMultiHandlerManager

    public class MultiHandlerManager<H>
    extends java.lang.Object
    Manages an array of handlers.
    Since:
    0.18.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.CopyOnWriteArrayList<hu.akarnokd.rxjava3.debug.multihook.MultiHandlerManager.HandlerRegistration<H>> handlers
      The copy-on-write registry of handlers wrapped into a HandlerRegistration container to support disposing/unregistering a particular registration.
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiHandlerManager()
      Constructs an empty handler manager.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all handlers from this MultiHandlerManager.
      void forEach​(@NonNull Consumer<H> consumer)
      The given consumer is invoked with each registered handler instance.
      <S> void forEach​(S state, @NonNull BiConsumer<S,​H> consumer)
      The given consumer is invoked with each registered handler instance.
      boolean hasHandlers()
      Returns true if this manager has any handlers registered.
      @NonNull Disposable register​(H handler)
      Registers the specified handler instance with this MultiHandlerManager.
      • Methods inherited from class java.lang.Object

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

      • handlers

        protected final java.util.concurrent.CopyOnWriteArrayList<hu.akarnokd.rxjava3.debug.multihook.MultiHandlerManager.HandlerRegistration<H>> handlers
        The copy-on-write registry of handlers wrapped into a HandlerRegistration container to support disposing/unregistering a particular registration.
    • Constructor Detail

      • MultiHandlerManager

        public MultiHandlerManager()
        Constructs an empty handler manager.
    • Method Detail

      • register

        @NonNull
        public final @NonNull Disposable register​(@NonNull
                                                  H handler)
        Registers the specified handler instance with this MultiHandlerManager.

        Handlers don't have to be unique instances, if the same handler is registered multiple times, it will be invoked multiple times as well.

        This method is threadsafe.

        Parameters:
        handler - the handler to register
        Returns:
        the Disposable instance to unregister the handler.
      • forEach

        public final void forEach​(@NonNull
                                  @NonNull Consumer<H> consumer)
        The given consumer is invoked with each registered handler instance.

        Exceptions raised by the invocation of the consumer for a particular handler are printed to the console and the current thread's uncaught exception handler is notified.

        This method is threadsafe.

        Parameters:
        consumer - the consumer to invoke
      • forEach

        public final <S> void forEach​(S state,
                                      @NonNull
                                      @NonNull BiConsumer<S,​H> consumer)
        The given consumer is invoked with each registered handler instance.

        Exceptions raised by the invocation of the consumer for a particular handler are printed to the console and the current thread's uncaught exception handler is notified.

        This method is threadsafe.

        Type Parameters:
        S - the type of the extra state provided to the consumer
        Parameters:
        state - the extra state provided to the consumer
        consumer - the consumer to invoke
      • clear

        public final void clear()
        Removes all handlers from this MultiHandlerManager.

        This method is threadsafe.

      • hasHandlers

        public final boolean hasHandlers()
        Returns true if this manager has any handlers registered.

        This method is threadsafe.

        Returns:
        true if this manager has any handlers registered.