Package org.springframework.core
Class ReactiveAdapter
java.lang.Object
org.springframework.core.ReactiveAdapter
Adapter for a Reactive Streams
Publisher
to and from an async/reactive
type such as CompletableFuture
, RxJava Observable
, and others.
An adapter is typically obtained via ReactiveAdapterRegistry
.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionReactiveAdapter
(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toPublisherFunction, Function<Publisher<?>, Object> fromPublisherFunction) Constructor for an adapter with functions to convert the target reactive or async type to and from a Reactive Streams Publisher. -
Method Summary
Modifier and TypeMethodDescriptionfromPublisher
(Publisher<?> publisher) Adapt from the given Reactive Streams Publisher.Return the descriptor of the reactive type for the adapter.Class<?>
Shortcut forgetDescriptor().getReactiveType()
.boolean
Shortcut forgetDescriptor().isMultiValue()
.boolean
Shortcut forgetDescriptor().isNoValue()
.boolean
Shortcut forgetDescriptor().supportsEmpty()
.<T> Publisher<T>
toPublisher
(Object source) Adapt the given instance to a Reactive StreamsPublisher
.
-
Constructor Details
-
ReactiveAdapter
public ReactiveAdapter(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toPublisherFunction, Function<Publisher<?>, Object> fromPublisherFunction) Constructor for an adapter with functions to convert the target reactive or async type to and from a Reactive Streams Publisher.- Parameters:
descriptor
- the reactive type descriptortoPublisherFunction
- adapter to a PublisherfromPublisherFunction
- adapter from a Publisher
-
-
Method Details
-
getDescriptor
Return the descriptor of the reactive type for the adapter. -
getReactiveType
Shortcut forgetDescriptor().getReactiveType()
. -
isMultiValue
public boolean isMultiValue()Shortcut forgetDescriptor().isMultiValue()
. -
isNoValue
public boolean isNoValue()Shortcut forgetDescriptor().isNoValue()
. -
supportsEmpty
public boolean supportsEmpty()Shortcut forgetDescriptor().supportsEmpty()
. -
toPublisher
Adapt the given instance to a Reactive StreamsPublisher
.- Parameters:
source
- the source object to adapt from; if the given object isnull
,ReactiveTypeDescriptor.getEmptyValue()
is used.- Returns:
- the Publisher representing the adaptation
-
fromPublisher
Adapt from the given Reactive Streams Publisher.- Parameters:
publisher
- the publisher to adapt from- Returns:
- the reactive type instance representing the adapted publisher
-