Class ReactiveAdapterRegistryHelper
java.lang.Object
org.springframework.graphql.execution.ReactiveAdapterRegistryHelper
- Since:
- 1.3.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Flux
<T> toFluxFromCollection
(@Nullable Object result) Return aFlux
for the given result Object that represents a logical collection of values.static <T> reactor.core.publisher.Mono
<T> Return aMono
for the given Object by delegating totoMonoIfReactive(java.lang.Object)
, and then applyingMono.justOrEmpty(java.util.Optional<? extends T>)
if necessary.static @Nullable Object
toMonoIfReactive
(@Nullable Object result) Return aMono
for the given result Object if it can be adapted to aPublisher
viaReactiveAdapterRegistry
.static @Nullable Object
toMonoOrFluxIfReactive
(@Nullable Object result) Adapt the given result Object toMono
orFlux
if it can be adapted to a single or multi-valuePublisher
respectively viaReactiveAdapterRegistry
.static reactor.core.publisher.Flux
<?> toSubscriptionFlux
(@Nullable Object result) Return aFlux
for the given result Object, adapting to aPublisher
viaReactiveAdapterRegistry
or wrapping it asFlux
if necessary.
-
Constructor Details
-
ReactiveAdapterRegistryHelper
public ReactiveAdapterRegistryHelper()
-
-
Method Details
-
toMono
Return aMono
for the given Object by delegating totoMonoIfReactive(java.lang.Object)
, and then applyingMono.justOrEmpty(java.util.Optional<? extends T>)
if necessary.- Type Parameters:
T
- the type of element in the Mono to cast to- Parameters:
result
- the result Object to adapt- Returns:
- a
Mono
that represents the result
-
toMonoIfReactive
Return aMono
for the given result Object if it can be adapted to aPublisher
viaReactiveAdapterRegistry
. Multivalued publishers are collected to a List.- Parameters:
result
- the result Object to adapt- Returns:
- the same instance or a
Mono
if the object is known toReactiveAdapterRegistry
-
toMonoOrFluxIfReactive
Adapt the given result Object toMono
orFlux
if it can be adapted to a single or multi-valuePublisher
respectively viaReactiveAdapterRegistry
.- Parameters:
result
- the result Object to adapt- Returns:
- the same instance, a
Mono
, or aFlux
-
toSubscriptionFlux
Return aFlux
for the given result Object, adapting to aPublisher
viaReactiveAdapterRegistry
or wrapping it asFlux
if necessary.- Parameters:
result
- the result Object to adapt- Returns:
- a
Flux
, possibly empty if the result isnull
-
toFluxFromCollection
Return aFlux
for the given result Object that represents a logical collection of values. The Object must be aCollection
or a publisher of aCollection
, which is flattened withFlux.fromIterable(Iterable)
, or a multi-value publisher.- Type Parameters:
T
- the type of element in the collection to cast to- Parameters:
result
- the result Object to adapt- Returns:
- a
Flux
that represents the collection
-