public class FlowableConverter extends Object implements ReactiveTypeConverter<io.reactivex.Flowable>
Flowable
type.
toCompletionStagetoCompletionStage(Flowable)
method returns a CompletionStage
instance completed or failed
according to the stream emissions. The returned CompletionStage
is redeemed with the first emitted value,
null
if the stream is empty. If the stream emits multiple values, the first one is used, and the
CompletionStage
is completed with the first emitted item. Other items and potential error are ignored. If
the stream fails before emitting a first item, the CompletionStage
is completed with the failure.
fromCompletionStagefromCompletionStage(CompletionStage)
method returns a Flowable
instance completed or failed
according to the passed CompletionStage
completion. Note that if the future emits a null
value,
the Flowable
fails. If the future completes with a value, the observable emits the value and then completes.
If the future completes with a failure, the stream emits the failure.
fromPublisherfromPublisher(Publisher)
method returns a Flowable
emitting the same items, failure and
completion as the passed Publisher
. If the passed Publisher
is empty, the returned Flowable
is also empty. This operation is a pass-through for back-pressure and its behavior is determined by the back-pressure
behavior of the passed publisher. This operation uses Flowable.fromPublisher(Publisher)
. If the passed
Publisher
is already a Flowable
, the instance is used directly.
toRSPublishertoRSPublisher(Flowable)
method returns a Publisher
emitting the same events as the source
Flowable
. This operation is a pass-through for back-pressure and its behavior is determined by the
back-pressure behavior of the passed Flowable
. This operation returns the passed Flowable
directly.Constructor and Description |
---|
FlowableConverter() |
Modifier and Type | Method and Description |
---|---|
boolean |
emitAtMostOneItem() |
boolean |
emitItems() |
<X> io.reactivex.Flowable |
fromCompletionStage(CompletionStage<X> cs)
Transforms an instance of
CompletionStage to an instance of T . |
io.reactivex.Flowable |
fromPublisher(org.reactivestreams.Publisher publisher)
Transforms an instance of
T to a Publisher . |
boolean |
supportNullValue() |
<T> CompletionStage<T> |
toCompletionStage(io.reactivex.Flowable instance)
Transforms an instance of
T to a CompletionStage completed with a potential value. |
<T> org.reactivestreams.Publisher<T> |
toRSPublisher(io.reactivex.Flowable instance)
Transforms an instance of
T to a Publisher . |
Class<io.reactivex.Flowable> |
type() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
requireAtLeastOneItem
public <T> org.reactivestreams.Publisher<T> toRSPublisher(io.reactivex.Flowable instance)
ReactiveTypeConverter
T
to a Publisher
.
Each converter instances can use specific rules, however the following set of rules are mandatory:
Publisher
must never be null
.instance
are emitted by the returned Publisher
.instance
emits a failure, Publisher
propagates the same failure and
terminates.instance
completes, Publisher
also completes.instance
does not emit any value and does not fail or complete, the returned
Publisher
does not send any signals or values.instance
completes beforePublisher
also completes empty.instance
emits null
, the Publisher
must send a failure
(NullPointerException
.instance
support back-pressure, the resulting Publisher
must enforce
back-pressure. When the instance
does not support back-pressure, the Publisher
consumes
the data without back-pressure using an unbounded-buffer. In other words, this operation is a pass-through
for back-pressure and its behavior is determined by the back-pressure behavior of the passed
instance
.toRSPublisher
in interface ReactiveTypeConverter<io.reactivex.Flowable>
T
- the type emitted by the returned Publisher
. It
is generally the type of data emitted by the passed instance
.instance
- the instance to convert to a Publisher
. Must not be null
.non-null
Publisher
.public io.reactivex.Flowable fromPublisher(org.reactivestreams.Publisher publisher)
ReactiveTypeConverter
T
to a Publisher
.
Each converter instances can use specific rules, however the following set of rules are mandatory:
Publisher
must never be null
.T
emits a single value, the returned Publisher
emits the same value
and completes.T
does not emits value, sends the completion signal, the returned
Publisher
completes.T
emits a failure, the returned Publisher
emits a failure.T
emits a null
value, the returned Publisher
emits an
NullPointerException
as null
is not a valid value.T
does neither emits a value nor a signal, the returned Publisher
does not emits values or signals.fromPublisher
in interface ReactiveTypeConverter<io.reactivex.Flowable>
publisher
- the Publisher
to convert. Must not be null
.non-null
instance of T
.public <T> CompletionStage<T> toCompletionStage(io.reactivex.Flowable instance)
ReactiveTypeConverter
T
to a CompletionStage
completed with a potential value.
Each converter instances can use specific rules, however the following set of rules are mandatory:
CompletionStage
must never be null
.CompletionStage
completes with the first emitted value. This value may be null
for empty stream or instance of T
emitting null
as first value.instance
emits several values, only the first one is considered, others are
discarded.instance
fails before emitting a value, the returned CompletionStage
completes with this failure.instance
does not emit any value and does not fail or complete, the returned
CompletionStage
does not complete.instance
completes beforeCompletionStage
is completed with a null
value.instance
emits null
as first value (if supported), the
CompletionStage
is completed with null
. As a consequence, there are no
differences between an instance
emitting null
as first value or completing without emitting
a value. If the instance
does not support emitting null
values, the returned
CompletionStage
must be completed with a failure.toCompletionStage
in interface ReactiveTypeConverter<io.reactivex.Flowable>
T
- the type used to complete the returned CompletionStage
.
It is generally the type of data emitted by the passed instance
.instance
- the instance to convert to a CompletionStage
. Must not be null
.non-null
CompletionStage
.public <X> io.reactivex.Flowable fromCompletionStage(CompletionStage<X> cs)
ReactiveTypeConverter
CompletionStage
to an instance of T
. The value emitted by T
depends on the completion of the passed CompletionStage
. Each converter instances can use specific rules,
however the following set of rules are mandatory:
T
must never be null
.CompletionStage
never completes, no values are emitted by the returned
T
.CompletionStage
redeems a null
value, and if T
support null
values, null
is emitted by the returned instance of T
.CompletionStage
redeems a null
value, and if T
does not support
null
values, a failure is emitted by the returned instance of T
.CompletionStage
redeems a non-null
value, the value is emitted by the
returned instance of T
.CompletionStage
is completed with a failure, the same failure is emitted by
the returned instance of T
.CompletionStage
is cancelled before having completed, the
CancellationException
must be emitted by the returned instance.
Implementations must not expect the CompletionStage
to be instances of
CompletableFuture
.
Implementations may decide to adapt the emitted result when receiving container object such as Optional
.
fromCompletionStage
in interface ReactiveTypeConverter<io.reactivex.Flowable>
X
- the type of result provided by the CompletionStage
cs
- the instance of CompletionStage
, must not be null
X
.public Class<io.reactivex.Flowable> type()
type
in interface ReactiveTypeConverter<io.reactivex.Flowable>
null
. Notice that sub-classes of the returned class are also
managed by the same converter.public boolean emitItems()
emitItems
in interface ReactiveTypeConverter<io.reactivex.Flowable>
true
if the type T
may emit items, false
otherwise.public boolean emitAtMostOneItem()
emitAtMostOneItem
in interface ReactiveTypeConverter<io.reactivex.Flowable>
true
if the type T
may emit items at most one item, false
otherwise. Returning
false
to this method means that the converted type only signals about completion or error. Returning
true
means that ReactiveTypeConverter.emitItems()
must also return true
.public boolean supportNullValue()
supportNullValue
in interface ReactiveTypeConverter<io.reactivex.Flowable>
true
if the type T
can emit or receive null
as item.Copyright © 2018–2019 SmallRye. All rights reserved.