Class MultiHandlerManager<H>

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

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

      • handlers

        protected final 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.