public class ReactiveAdapter extends Object
Publisher
to and from an async/reactive type
such as CompletableFuture
, an RxJava Observable
, etc.
Use the ReactiveAdapterRegistry
to register reactive types and
obtain adapters from.
Constructor and Description |
---|
ReactiveAdapter(ReactiveTypeDescriptor descriptor,
Function<Object,org.reactivestreams.Publisher<?>> toPublisherFunction,
Function<org.reactivestreams.Publisher<?>,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 |
---|---|
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.
|
Class<?> |
getReactiveType()
A shortcut for
getDescriptor().getReactiveType() . |
boolean |
isMultiValue()
A shortcut for
getDescriptor().isMultiValue() . |
boolean |
isNoValue()
A shortcut for
getDescriptor().isNoValue() . |
boolean |
supportsEmpty()
A shortcut for
getDescriptor().supportsEmpty() . |
<T> org.reactivestreams.Publisher<T> |
toPublisher(Object source)
Adapt the given instance to a Reactive Streams Publisher.
|
public ReactiveAdapter(ReactiveTypeDescriptor descriptor, Function<Object,org.reactivestreams.Publisher<?>> toPublisherFunction, Function<org.reactivestreams.Publisher<?>,Object> fromPublisherFunction)
descriptor
- the reactive type descriptortoPublisherFunction
- adapter to a PublisherfromPublisherFunction
- adapter from a Publisherpublic ReactiveTypeDescriptor getDescriptor()
public 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 Object source)
source
- the source object to adapt frompublic Object fromPublisher(org.reactivestreams.Publisher<?> publisher)
publisher
- the publisher to adapt from