public class ReactiveAdapter extends 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,
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()
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(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 isNoValue()
getDescriptor().isNoValue()
.public boolean supportsEmpty()
getDescriptor().supportsEmpty()
.public <T> org.reactivestreams.Publisher<T> toPublisher(@Nullable Object source)
Publisher
.source
- the source object to adapt from; if the given object is
null
, ReactiveTypeDescriptor.getEmptyValue()
is used.public Object fromPublisher(org.reactivestreams.Publisher<?> publisher)
publisher
- the publisher to adapt from