Package org.springframework.core
Class ReactiveAdapter
- java.lang.Object
- org.springframework.core.ReactiveAdapter
public class ReactiveAdapter extends Object
Adapter for a Reactive StreamsPublisherto and from an async/reactive type such asCompletableFuture, RxJavaObservable, and others.An adapter is typically obtained via
ReactiveAdapterRegistry.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor 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.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectfromPublisher(org.reactivestreams.Publisher<?> publisher)Adapt from the given Reactive Streams Publisher.ReactiveTypeDescriptorgetDescriptor()Return the descriptor of the reactive type for the adapter.Class<?>getReactiveType()Shortcut forgetDescriptor().getReactiveType().booleanisMultiValue()Shortcut forgetDescriptor().isMultiValue().booleanisNoValue()Shortcut forgetDescriptor().isNoValue().booleansupportsEmpty()Shortcut forgetDescriptor().supportsEmpty().<T> org.reactivestreams.Publisher<T>toPublisher(Object source)Adapt the given instance to a Reactive StreamsPublisher.
Constructor Detail
ReactiveAdapter
public 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.- Parameters:
descriptor- the reactive type descriptortoPublisherFunction- adapter to a PublisherfromPublisherFunction- adapter from a Publisher
Method Detail
getDescriptor
public ReactiveTypeDescriptor getDescriptor()
Return the descriptor of the reactive type for the adapter.
getReactiveType
public Class<?> 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
public <T> org.reactivestreams.Publisher<T> toPublisher(@Nullable Object source)
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
public Object fromPublisher(org.reactivestreams.Publisher<?> publisher)
Adapt from the given Reactive Streams Publisher.- Parameters:
publisher- the publisher to adapt from- Returns:
- the reactive type instance representing the adapted publisher