public class ReactiveAdapter
extends java.lang.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.
Modifier and Type | Field and Description |
---|---|
private ReactiveTypeDescriptor |
descriptor |
private java.util.function.Function<<any>,java.lang.Object> |
fromPublisherFunction |
private java.util.function.Function<java.lang.Object,<any>> |
toPublisherFunction |
Constructor and Description |
---|
ReactiveAdapter(ReactiveTypeDescriptor descriptor,
java.util.function.Function<java.lang.Object,<any>> toPublisherFunction,
java.util.function.Function<<any>,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(<any> publisher)
Adapt from the given Reactive Streams Publisher.
|
ReactiveTypeDescriptor |
getDescriptor()
Return the descriptor of the reactive type for the adapter.
|
java.lang.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> <any> |
toPublisher(java.lang.Object source)
Adapt the given instance to a Reactive Streams Publisher.
|
private final ReactiveTypeDescriptor descriptor
private final java.util.function.Function<java.lang.Object,<any>> toPublisherFunction
private final java.util.function.Function<<any>,java.lang.Object> fromPublisherFunction
public ReactiveAdapter(ReactiveTypeDescriptor descriptor, java.util.function.Function<java.lang.Object,<any>> toPublisherFunction, java.util.function.Function<<any>,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> <any> toPublisher(@Nullable java.lang.Object source)
source
- the source object to adapt frompublic java.lang.Object fromPublisher(<any> publisher)
publisher
- the publisher to adapt from