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.
| 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. |
Returns true if this adapter can convert instances of the given
type to Awaitable (single-value async result).
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).
Converts the given source object to an Awaitable.
Called only when supportsAwaitable returned true.
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.