Class ReactiveAdapterRegistryHelper

java.lang.Object
org.springframework.graphql.execution.ReactiveAdapterRegistryHelper

public abstract class ReactiveAdapterRegistryHelper extends Object
Helper to adapt a result Object to Mono or Flux through ReactiveAdapterRegistry.
Since:
1.3.1
Author:
Rossen Stoyanchev
  • Constructor Details

    • ReactiveAdapterRegistryHelper

      public ReactiveAdapterRegistryHelper()
  • Method Details

    • toMono

      public static <T> reactor.core.publisher.Mono<T> toMono(@Nullable Object result)
      Return a Mono for the given Object by delegating to toMonoIfReactive(java.lang.Object), and then applying Mono.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

      @Nullable public static Object toMonoIfReactive(@Nullable Object result)
      Return a Mono for the given result Object if it can be adapted to a Publisher via ReactiveAdapterRegistry. 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 to ReactiveAdapterRegistry
    • toMonoOrFluxIfReactive

      @Nullable public static Object toMonoOrFluxIfReactive(@Nullable Object result)
      Adapt the given result Object to Mono or Flux if it can be adapted to a single or multi-value Publisher respectively via ReactiveAdapterRegistry.
      Parameters:
      result - the result Object to adapt
      Returns:
      the same instance, a Mono, or a Flux
    • toSubscriptionFlux

      public static reactor.core.publisher.Flux<?> toSubscriptionFlux(@Nullable Object result)
      Return a Flux for the given result Object, adapting to a Publisher first if necessary via ReactiveAdapterRegistry.
      Parameters:
      result - the result Object to adapt
      Returns:
      a Flux, possibly empty if the result is null
    • toFluxFromCollection

      public static <T> reactor.core.publisher.Flux<T> toFluxFromCollection(@Nullable Object result)
      Return a Flux for the given result Object that represents a logical collection of values. The Object must be a Collection or a publisher of a Collection, which is flattened with Flux.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