类 ReactiveAdapter
- java.lang.Object
- org.springframework.core.ReactiveAdapter
public class ReactiveAdapter extends Object
Adapter for a Reactive StreamsPublisher
to and from an async/reactive type such asCompletableFuture
, RxJavaObservable
, and others.An adapter is typically obtained via
ReactiveAdapterRegistry
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 forgetDescriptor().getReactiveType()
.boolean
isMultiValue()
Shortcut forgetDescriptor().isMultiValue()
.boolean
isNoValue()
Shortcut forgetDescriptor().isNoValue()
.boolean
supportsEmpty()
Shortcut forgetDescriptor().supportsEmpty()
.<T> org.reactivestreams.Publisher<T>
toPublisher(Object source)
Adapt the given instance to a Reactive StreamsPublisher
.
构造器详细资料
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.- 参数:
descriptor
- the reactive type descriptortoPublisherFunction
- adapter to a PublisherfromPublisherFunction
- adapter from a Publisher
方法详细资料
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
.- 参数:
source
- the source object to adapt from; if the given object isnull
,ReactiveTypeDescriptor.getEmptyValue()
is used.- 返回:
- the Publisher representing the adaptation
fromPublisher
public Object fromPublisher(org.reactivestreams.Publisher<?> publisher)
Adapt from the given Reactive Streams Publisher.- 参数:
publisher
- the publisher to adapt from- 返回:
- the reactive type instance representing the adapted publisher