Class ReactiveAdapterRegistryHelper
java.lang.Object
org.springframework.graphql.execution.ReactiveAdapterRegistryHelper
- Since:
- 1.3.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Flux<T>
toFluxFromCollection
(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 Object
toMonoIfReactive
(Object result) Return aMono
for the given result Object if it can be adapted to aPublisher
viaReactiveAdapterRegistry
.static Object
toMonoOrFluxIfReactive
(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
(Object result) Return aFlux
for the given result Object, adapting to aPublisher
first if necessary viaReactiveAdapterRegistry
.
-
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
first if necessary viaReactiveAdapterRegistry
.- 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
-