Interface Processor<I,O>
-
- Type Parameters:
I
- The type observedO
- The type produced
- All Superinterfaces:
Publisher<O>
,Subscriber<I>
- All Known Subinterfaces:
Processor.Iso<V>
,Processor.Transactional<I,O>
,Processor.TransactionalIso<V>
public interface Processor<I,O> extends Publisher<O>, Subscriber<I>
A combination of anPublisher
andSubscriber
.Processors are expected to broadcast their submitted values to any registered observers, though filtering or other transformations may be applied.
Submitting a completion event to the processor will result in a completion event being passed to every subscriber, and the rejection of further events being submitted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Processor.Iso<V>
A Processor that has the same type for inputs and outputsstatic interface
Processor.Transactional<I,O>
static interface
Processor.TransactionalIso<V>
-
Nested classes/interfaces inherited from interface ninja.leaping.configurate.reactive.Publisher
Publisher.Cached<V>
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
closeIfUnsubscribed()
Close this processor if there are no remaining subscriptions.static <V> Processor.Iso<V>
create()
Create aProcessor
instance that simply broadcasts submitted values to its subscribers.static <V> Processor.Iso<V>
create(Executor executor)
Create aProcessor
instance that simply broadcasts submitted values to its subscribersstatic <V> Processor.TransactionalIso<V>
createTransactional()
Create a processor instance that is aware of transactionsstatic <V> Processor.TransactionalIso<V>
createTransactional(Executor exec)
void
inject(O element)
Submit an element of the observed type, bypassing any mapping this Processor may do.default <R> Processor<O,R>
map(CheckedFunction<? super O,? extends R,TransactionFailedException> mapper)
void
setFallbackHandler(@Nullable Subscriber<O> subscriber)
Provide aSubscriber
that will handle events submitted to this processor, but only if no other subscription is active.-
Methods inherited from interface ninja.leaping.configurate.reactive.Publisher
cache, cache, getExecutor, hasSubscribers, subscribe
-
Methods inherited from interface ninja.leaping.configurate.reactive.Subscriber
onClose, onError, submit
-
-
-
-
Method Detail
-
create
static <V> Processor.Iso<V> create()
Create aProcessor
instance that simply broadcasts submitted values to its subscribers. Broadcasts will occur on the commonForkJoinPool
.- Type Parameters:
V
- The type- Returns:
- A new processor instance
-
createTransactional
static <V> Processor.TransactionalIso<V> createTransactional()
Create a processor instance that is aware of transactions- Type Parameters:
V
- The value type- Returns:
- a new transactional processor
-
create
static <V> Processor.Iso<V> create(Executor executor)
Create aProcessor
instance that simply broadcasts submitted values to its subscribers- Type Parameters:
V
- The type- Parameters:
executor
- task executor- Returns:
- A new processor instance
-
createTransactional
static <V> Processor.TransactionalIso<V> createTransactional(Executor exec)
-
map
default <R> Processor<O,R> map(CheckedFunction<? super O,? extends R,TransactionFailedException> mapper)
-
inject
void inject(O element)
Submit an element of the observed type, bypassing any mapping this Processor may do. If the input type of this processor equals the output type, this is equivalent toSubscriber.submit(Object)
- Parameters:
element
- The element to submit
-
setFallbackHandler
void setFallbackHandler(@Nullable Subscriber<O> subscriber)
Provide aSubscriber
that will handle events submitted to this processor, but only if no other subscription is active.- Parameters:
subscriber
- The fallback subscriber to add. Providenull
to remove the handler
-
closeIfUnsubscribed
boolean closeIfUnsubscribed()
Close this processor if there are no remaining subscriptions. Any signals that have already been submitted will be processed.Any call to this method after the
Processor
has been closed will simply return true.- Returns:
- true if there are no subscribers and this processor is closed
-
-