Package org.apache.groovy.reactor

# 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 Summary

  Constructors
  Constructor
  Description
  `ReactorAwaitableAdapter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `supportsAwaitable(Class<?> type)`
  Returns whether the supplied type can be awaited as a Reactor single-result source.
  `boolean`
  `supportsIterable(Class<?> type)`
  Returns whether the supplied type can be exposed as an iterable Reactor multi-result source.
  `<T> Awaitable<T>`
  `toAwaitable(Object source)`
  Converts a `Mono` into an `Awaitable` backed by the mono's future view.
  `<T> Iterable<T>`
  `toIterable(Object source)`
  Converts a `Flux` into a blocking `Iterable` suitable for `for await` consumption.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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`