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(Object result) Return aFluxfor the given result Object that represents a logical collection of values.static <T> reactor.core.publisher.Mono<T> Return aMonofor the given Object by delegating totoMonoIfReactive(java.lang.Object), and then applyingMono.justOrEmpty(java.util.Optional<? extends T>)if necessary.static ObjecttoMonoIfReactive(Object result) Return aMonofor the given result Object if it can be adapted to aPublisherviaReactiveAdapterRegistry.static ObjecttoMonoOrFluxIfReactive(Object result) Adapt the given result Object toMonoorFluxif it can be adapted to a single or multi-valuePublisherrespectively viaReactiveAdapterRegistry.static reactor.core.publisher.Flux<?> toSubscriptionFlux(Object result) Return aFluxfor the given result Object, adapting to aPublisherviaReactiveAdapterRegistryor wrapping it asFluxif necessary.
-
Constructor Details
-
ReactiveAdapterRegistryHelper
public ReactiveAdapterRegistryHelper()
-
-
Method Details
-
toMono
Return aMonofor 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
Monothat represents the result
-
toMonoIfReactive
Return aMonofor the given result Object if it can be adapted to aPublisherviaReactiveAdapterRegistry. Multivalued publishers are collected to a List.- Parameters:
result- the result Object to adapt- Returns:
- the same instance or a
Monoif the object is known toReactiveAdapterRegistry
-
toMonoOrFluxIfReactive
Adapt the given result Object toMonoorFluxif it can be adapted to a single or multi-valuePublisherrespectively viaReactiveAdapterRegistry.- Parameters:
result- the result Object to adapt- Returns:
- the same instance, a
Mono, or aFlux
-
toSubscriptionFlux
Return aFluxfor the given result Object, adapting to aPublisherviaReactiveAdapterRegistryor wrapping it asFluxif necessary.- Parameters:
result- the result Object to adapt- Returns:
- a
Flux, possibly empty if the result isnull
-
toFluxFromCollection
Return aFluxfor the given result Object that represents a logical collection of values. The Object must be aCollectionor 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
Fluxthat represents the collection
-