Class MultiHandlerManager<H>
- java.lang.Object
-
- hu.akarnokd.rxjava3.debug.multihook.MultiHandlerManager<H>
-
- Type Parameters:
H- the handler type
- Direct Known Subclasses:
OnScheduleMultiHandlerManager
public class MultiHandlerManager<H> extends java.lang.ObjectManages 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>>handlersThe 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 voidclear()Removes all handlers from this MultiHandlerManager.voidforEach(@NonNull Consumer<H> consumer)The given consumer is invoked with each registered handler instance.<S> voidforEach(S state, @NonNull BiConsumer<S,H> consumer)The given consumer is invoked with each registered handler instance.booleanhasHandlers()Returns true if this manager has any handlers registered.@NonNull Disposableregister(H handler)Registers the specified handler instance with this MultiHandlerManager.
-
-
-
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.
-
-
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 consumerconsumer- 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.
-
-