public class ReactiveAdapter
extends java.lang.Object
Publisher to and from an async/reactive
type such as CompletableFuture, RxJava Observable, and others.
An adapter is typically obtained via ReactiveAdapterRegistry.
| Constructor and Description |
|---|
ReactiveAdapter(ReactiveTypeDescriptor descriptor,
java.util.function.Function<java.lang.Object,org.reactivestreams.Publisher<?>> toPublisherFunction,
java.util.function.Function<org.reactivestreams.Publisher<?>,java.lang.Object> fromPublisherFunction)
Constructor for an adapter with functions to convert the target reactive
or async type to and from a Reactive Streams Publisher.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
fromPublisher(org.reactivestreams.Publisher<?> publisher)
Adapt from the given Reactive Streams Publisher.
|
ReactiveTypeDescriptor |
getDescriptor()
Return the descriptor of the reactive type for the adapter.
|
java.lang.Class<?> |
getReactiveType()
Shortcut for
getDescriptor().getReactiveType(). |
boolean |
isMultiValue()
Shortcut for
getDescriptor().isMultiValue(). |
boolean |
isNoValue()
Shortcut for
getDescriptor().isNoValue(). |
boolean |
supportsEmpty()
Shortcut for
getDescriptor().supportsEmpty(). |
<T> org.reactivestreams.Publisher<T> |
toPublisher(java.lang.Object source)
Adapt the given instance to a Reactive Streams
Publisher. |
public ReactiveAdapter(ReactiveTypeDescriptor descriptor, java.util.function.Function<java.lang.Object,org.reactivestreams.Publisher<?>> toPublisherFunction, java.util.function.Function<org.reactivestreams.Publisher<?>,java.lang.Object> fromPublisherFunction)
descriptor - the reactive type descriptortoPublisherFunction - adapter to a PublisherfromPublisherFunction - adapter from a Publisherpublic ReactiveTypeDescriptor getDescriptor()
public java.lang.Class<?> getReactiveType()
getDescriptor().getReactiveType().public boolean isMultiValue()
getDescriptor().isMultiValue().public boolean supportsEmpty()
getDescriptor().supportsEmpty().public boolean isNoValue()
getDescriptor().isNoValue().public <T> org.reactivestreams.Publisher<T> toPublisher(@Nullable java.lang.Object source)
Publisher.source - the source object to adapt from; if the given object is
null, ReactiveTypeDescriptor.getEmptyValue() is used.public java.lang.Object fromPublisher(org.reactivestreams.Publisher<?> publisher)
publisher - the publisher to adapt from