Package: groovy.concurrent

## [Java] Interface AwaitableAdapter

-     public interface AwaitableAdapter

  Service Provider Interface (SPI) for adapting third-party asynchronous types to Groovy's Awaitable abstraction and to iterables for `for await` loops.

  Implementations are discovered automatically via ServiceLoader. To register an adapter, create a file `META-INF/services/groovy.concurrent.AwaitableAdapter` containing the fully-qualified class name of your implementation.

  See Also:
    AwaitableAdapterRegistry
  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `supportsAwaitable(Class<?> type)` Returns `true` if this adapter can convert instances of the given type to Awaitable (single-value async result).
    `` | `public boolean` | `supportsIterable(Class<?> type)` Returns `true` if this adapter can convert instances of the given type to an Iterable for `for await` loops.
    `<T>` | `public Awaitable<T>` | `toAwaitable(Object source)` Converts the given source object to an Awaitable.
    `<T>` | `public Iterable<T>` | `toIterable(Object source)` Converts the given source object to an Iterable.

- - ### Method Detail

    - #### public boolean supportsAwaitable(Class<?> type)

      Returns `true` if this adapter can convert instances of the given type to Awaitable (single-value async result).

    - #### public boolean supportsIterable(Class<?> type)

      Returns `true` if this adapter can convert instances of the given type to an Iterable for `for await` loops. Defaults to `false`; override for multi-value async types (e.g., Reactor `Flux`, RxJava `Observable`).

    - #### <T> public Awaitable<T> toAwaitable(Object source)

      Converts the given source object to an Awaitable. Called only when supportsAwaitable returned `true`.

    - #### <T> public Iterable<T> toIterable(Object source)

      Converts the given source object to an Iterable. Called only when supportsIterable returned `true`. The returned iterable typically blocks on `next()` until the next element is available — with virtual threads this is efficient.