Top Description Fields Constructors Methods
org.springframework.core

public Class ReactiveAdapter

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.core.ReactiveAdapterRegistry.ReactorAdapter
Imports
java.util.function.Function, org.reactivestreams.Publisher, org.springframework.lang.Nullable, org.springframework.util.Assert

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.

Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
private final ReactiveTypeDescriptor
private final Function<Publisher<?>, Object>
private final Function<Object, Publisher<?>>

Constructor Summary

AccessConstructor and Description
public
ReactiveAdapter(ReactiveTypeDescriptor
the reactive type descriptor
descriptor
,
Function<Object, Publisher<?>>
adapter to a Publisher
toPublisherFunction
,
Function<Publisher<?>, Object>
adapter from a Publisher
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 TypeMethod and Description
public Object

Returns:

the reactive type instance representing the adapted publisher
fromPublisher
(Publisher<?>
the publisher to adapt from
publisher
)

Adapt from the given Reactive Streams Publisher.

public ReactiveTypeDescriptor
getDescriptor()

Return the descriptor of the reactive type for the adapter.

public Class<?>
getReactiveType()

Shortcut for getDescriptor().getReactiveType().

public boolean
isMultiValue()

Shortcut for getDescriptor().isMultiValue().

public boolean
isNoValue()

Shortcut for getDescriptor().isNoValue().

public boolean
supportsEmpty()

Shortcut for getDescriptor().supportsEmpty().

public <T> Publisher<T>

Returns:

the Publisher representing the adaptation
toPublisher
(Object
the source object to adapt from; if the given object is null, ReactiveTypeDescriptor#getEmptyValue() is used.
source
)

Adapt the given instance to a Reactive Streams Publisher.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descriptorback to summary
private final ReactiveTypeDescriptor descriptor
fromPublisherFunctionback to summary
private final Function<Publisher<?>, Object> fromPublisherFunction
toPublisherFunctionback to summary
private final Function<Object, Publisher<?>> toPublisherFunction

Constructor Detail

ReactiveAdapterback to summary
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:ReactiveTypeDescriptor

the reactive type descriptor

toPublisherFunction:Function<Object, Publisher<?>>

adapter to a Publisher

fromPublisherFunction:Function<Publisher<?>, Object>

adapter from a Publisher

Method Detail

fromPublisherback to summary
public Object fromPublisher(Publisher<?> publisher)

Adapt from the given Reactive Streams Publisher.

Parameters
publisher:Publisher<?>

the publisher to adapt from

Returns:Object

the reactive type instance representing the adapted publisher

getDescriptorback to summary
public ReactiveTypeDescriptor getDescriptor()

Return the descriptor of the reactive type for the adapter.

getReactiveTypeback to summary
public Class<?> getReactiveType()

Shortcut for getDescriptor().getReactiveType().

isMultiValueback to summary
public boolean isMultiValue()

Shortcut for getDescriptor().isMultiValue().

isNoValueback to summary
public boolean isNoValue()

Shortcut for getDescriptor().isNoValue().

supportsEmptyback to summary
public boolean supportsEmpty()

Shortcut for getDescriptor().supportsEmpty().

toPublisherback to summary
public <T> Publisher<T> toPublisher(Object source)

Adapt the given instance to a Reactive Streams Publisher.

Parameters
source:Object

the source object to adapt from; if the given object is null, ReactiveTypeDescriptor#getEmptyValue() is used.

Returns:Publisher<T>

the Publisher representing the adaptation

Annotations
@SuppressWarnings:unchecked