public interface ReactiveStreamsFactory
ReactiveStreams
.Modifier and Type | Method and Description |
---|---|
<T> ProcessorBuilder<T,T> |
builder()
Create a
ProcessorBuilder . |
<T> PublisherBuilder<T> |
concat(PublisherBuilder<? extends T> a,
PublisherBuilder<? extends T> b)
Concatenates two publishers.
|
<T,R> ProcessorBuilder<T,R> |
coupled(org.reactivestreams.Subscriber<? super T> subscriber,
org.reactivestreams.Publisher<? extends R> publisher)
|
<T,R> ProcessorBuilder<T,R> |
coupled(SubscriberBuilder<? super T,?> subscriber,
PublisherBuilder<? extends R> publisher)
|
<T> PublisherBuilder<T> |
empty()
Create an empty
PublisherBuilder . |
<T> PublisherBuilder<T> |
failed(Throwable t)
Create a failed
PublisherBuilder . |
<T> PublisherBuilder<T> |
fromCompletionStage(CompletionStage<? extends T> completionStage)
Creates a publisher from a
CompletionStage . |
<T> PublisherBuilder<T> |
fromCompletionStageNullable(CompletionStage<? extends T> completionStage)
Creates a publisher from a
CompletionStage . |
<T> PublisherBuilder<T> |
fromIterable(Iterable<? extends T> ts)
Create a
PublisherBuilder that will emits the elements produced by the passed in Iterable . |
<T,R> ProcessorBuilder<T,R> |
fromProcessor(org.reactivestreams.Processor<? super T,? extends R> processor)
Create a
ProcessorBuilder from the given Processor . |
<T> PublisherBuilder<T> |
fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
Create a
PublisherBuilder from the given Publisher . |
<T> SubscriberBuilder<T,Void> |
fromSubscriber(org.reactivestreams.Subscriber<? extends T> subscriber)
Create a
SubscriberBuilder from the given Subscriber . |
<T> PublisherBuilder<T> |
generate(Supplier<? extends T> s)
Creates an infinite stream that emits elements supplied by the supplier
s . |
<T> PublisherBuilder<T> |
iterate(T seed,
UnaryOperator<T> f)
Creates an infinite stream produced by the iterative application of the function
f to an initial element
seed consisting of seed , f(seed) , f(f(seed)) , etc. |
<T> PublisherBuilder<T> |
of(T... ts)
Create a
PublisherBuilder that emits the given elements. |
<T> PublisherBuilder<T> |
of(T t)
Create a
PublisherBuilder that emits a single element. |
<T> PublisherBuilder<T> |
ofNullable(T t)
Create a
PublisherBuilder that will emit a single element if t is not null, otherwise will be
empty. |
<T> PublisherBuilder<T> fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
PublisherBuilder
from the given Publisher
.T
- The type of the elements that the publisher produces.publisher
- The publisher to wrap.<T> PublisherBuilder<T> of(T t)
PublisherBuilder
that emits a single element.
T
- The type of the element.t
- The element to emit.<T> PublisherBuilder<T> of(T... ts)
PublisherBuilder
that emits the given elements.
T
- The type of the elements.ts
- The elements to emit.<T> PublisherBuilder<T> empty()
PublisherBuilder
.
T
- The type of the publisher builder.<T> PublisherBuilder<T> ofNullable(T t)
PublisherBuilder
that will emit a single element if t
is not null, otherwise will be
empty.
T
- The type of the element.t
- The element to emit, null
if to element should be emitted.<T> PublisherBuilder<T> fromIterable(Iterable<? extends T> ts)
T
- The type of the elements.ts
- The elements to emit.<T> PublisherBuilder<T> failed(Throwable t)
T
- The type of the publisher builder.t
- The error te emit.<T> ProcessorBuilder<T,T> builder()
ProcessorBuilder
. This builder will start as an identity processor.
T
- The type of elements that the processor consumes and emits.<T,R> ProcessorBuilder<T,R> fromProcessor(org.reactivestreams.Processor<? super T,? extends R> processor)
ProcessorBuilder
from the given Processor
.T
- The type of the elements that the processor consumes.R
- The type of the elements that the processor emits.processor
- The processor to be wrapped.<T> SubscriberBuilder<T,Void> fromSubscriber(org.reactivestreams.Subscriber<? extends T> subscriber)
SubscriberBuilder
from the given Subscriber
.
The subscriber can only be used to create a single subscriber builder.T
- The type of elements that the subscriber consumes.subscriber
- The subscriber to be wrapped.<T> PublisherBuilder<T> iterate(T seed, UnaryOperator<T> f)
f
to an initial element
seed
consisting of seed
, f(seed)
, f(f(seed))
, etc.
T
- The type of stream elements.seed
- The initial element.f
- A function applied to the previous element to produce the next element.<T> PublisherBuilder<T> generate(Supplier<? extends T> s)
s
.
T
- The type of stream elements.s
- The supplier.<T> PublisherBuilder<T> concat(PublisherBuilder<? extends T> a, PublisherBuilder<? extends T> b)
The resulting stream will be produced by subscribing to the first publisher, and emitting the elements it emits, until it emits a completion signal, at which point the second publisher will be subscribed to, and its elements will be emitted.
If the first publisher completes with an error signal, then the second publisher will be subscribed to but immediately cancelled, none of its elements will be emitted. This ensures that hot publishers are cleaned up. If downstream emits a cancellation signal before the first publisher finishes, it will be passed to both publishers.
T
- The type of stream elements.a
- The first publisher.b
- The second publisher.<T> PublisherBuilder<T> fromCompletionStage(CompletionStage<? extends T> completionStage)
CompletionStage
.
When the CompletionStage
is redeemed, the publisher will emit the redeemed element, and then signal
completion. If the completion stage is redeemed with null
, the stream will be failed with a
NullPointerException
.
If the CompletionStage
is completed with a failure, this failure will be propagated through the stream.
T
- The type of the CompletionStage
value.completionStage
- The CompletionStage
to create the publisher from.PublisherBuilder
representation of this CompletionStage
.<T> PublisherBuilder<T> fromCompletionStageNullable(CompletionStage<? extends T> completionStage)
CompletionStage
.
When the CompletionStage
is redeemed, the publisher will emit the redeemed element, and then signal
completion. If the completion stage is redeemed with null
, the stream will be immediately completed
with no element, ie, it will be an empty stream.
If the CompletionStage
is completed with a failure, this failure will be propagated through the stream.
T
- The type of the CompletionStage
value.completionStage
- The CompletionStage
to create the publisher from.PublisherBuilder
representation of this CompletionStage
.<T,R> ProcessorBuilder<T,R> coupled(SubscriberBuilder<? super T,?> subscriber, PublisherBuilder<? extends R> publisher)
ProcessorBuilder
by coupling a SubscriberBuilder
to a PublisherBuilder
.
The resulting processor sends all the elements received to the passed in subscriber, and emits all the elements received from the passed in publisher.
In addition, the lifecycles of the subscriber and publisher are coupled, such that if one terminates or receives a termination signal, the other will be terminated. Below is a table of what signals are emited when:
Returned ProcessorBuilder inlet | Passed in SubscriberBuilder | Passed in PublisherBuilder | Returned ProcessorBuilder outlet |
---|---|---|---|
Cause: complete from upstream | Effect: complete | Effect: cancel | Effect: complete |
Cause: error from upstream | Effect: error | Effect: cancel | Effect: error |
Effect: cancel | Cause: cancels | Effect: cancel | Effect: complete |
Effect: cancel | Effect: complete | Cause: completes | Effect: complete |
Effect: cancel | Effect: error | Cause: errors | Effect: error |
Effect: cancel | Effect: complete | Effect: cancel | Cause: cancel from downstream |
T
- The type of elements received.R
- The type of elements emitted.subscriber
- The subscriber builder to wrap.publisher
- The publisher builder to wrap.<T,R> ProcessorBuilder<T,R> coupled(org.reactivestreams.Subscriber<? super T> subscriber, org.reactivestreams.Publisher<? extends R> publisher)
ProcessorBuilder
by coupling a Subscriber
to a Publisher
.
The resulting processor sends all the elements received to the passed in subscriber, and emits all the elements received from the passed in publisher.
In addition, the lifecycles of the subscriber and publisher are coupled, such that if one terminates or receives a termination signal, the other will be terminated. Below is a table of what signals are emited when:
Returned ProcessorBuilder inlet | Passed in SubscriberBuilder | Passed in PublisherBuilder | Returned ProcessorBuilder outlet |
---|---|---|---|
Cause: complete from upstream | Effect: complete | Effect: cancel | Effect: complete |
Cause: error from upstream | Effect: error | Effect: cancel | Effect: error |
Effect: cancel | Cause: cancels | Effect: cancel | Effect: complete |
Effect: cancel | Effect: complete | Cause: completes | Effect: complete |
Effect: cancel | Effect: error | Cause: errors | Effect: error |
Effect: cancel | Effect: complete | Effect: cancel | Cause: cancel from downstream |
T
- The type of elements received.R
- The type of elements emitted.subscriber
- The subscriber builder to wrap.publisher
- The publisher builder to wrap.coupled(SubscriberBuilder, PublisherBuilder)
Copyright © 2019 Eclipse Foundation. All rights reserved.