Class ReactorAwaitableAdapter

java.lang.Object
org.apache.groovy.reactor.ReactorAwaitableAdapter
All Implemented Interfaces:
AwaitableAdapter

public class ReactorAwaitableAdapter extends Object implements AwaitableAdapter
Adapter for Project Reactor types, enabling:
  • await mono — awaits a single-value Mono
  • for await (item in flux) — iterates over a Flux

Auto-discovered via ServiceLoader when groovy-reactor is on the classpath.

Since:
6.0.0
  • Constructor Details

    • ReactorAwaitableAdapter

      public ReactorAwaitableAdapter()
  • Method Details

    • supportsAwaitable

      public boolean supportsAwaitable(Class<?> type)
      Returns whether the supplied type can be awaited as a Reactor single-result source.
      Specified by:
      supportsAwaitable in interface AwaitableAdapter
      Parameters:
      type - candidate type to inspect
      Returns:
      true if type is a Mono or one of its subtypes
    • toAwaitable

      public <T> Awaitable<T> toAwaitable(Object source)
      Converts a Mono into an Awaitable backed by the mono's future view.
      Specified by:
      toAwaitable in interface AwaitableAdapter
      Type Parameters:
      T - awaited value type
      Parameters:
      source - source object to adapt
      Returns:
      awaitable representation of the supplied Mono
      Throws:
      IllegalArgumentException - if source is not a Mono
    • supportsIterable

      public boolean supportsIterable(Class<?> type)
      Returns whether the supplied type can be exposed as an iterable Reactor multi-result source.
      Specified by:
      supportsIterable in interface AwaitableAdapter
      Parameters:
      type - candidate type to inspect
      Returns:
      true if type is a Flux or one of its subtypes
    • toIterable

      public <T> Iterable<T> toIterable(Object source)
      Converts a Flux into a blocking Iterable suitable for for await consumption.
      Specified by:
      toIterable in interface AwaitableAdapter
      Type Parameters:
      T - iterated element type
      Parameters:
      source - source object to adapt
      Returns:
      iterable view of the supplied Flux
      Throws:
      IllegalArgumentException - if source is not a Flux