Package groovy.concurrent
Interface AwaitableAdapter
- All Known Implementing Classes:
FlowPublisherAdapter,ReactorAwaitableAdapter,RxJavaAwaitableAdapter
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.
- Since:
- 6.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleansupportsAwaitable(Class<?> type) Returnstrueif this adapter can convert instances of the given type toAwaitable(single-value async result).default booleansupportsIterable(Class<?> type) Returnstrueif this adapter can convert instances of the given type to anIterableforfor awaitloops.<T> Awaitable<T>toAwaitable(Object source) Converts the given source object to anAwaitable.default <T> Iterable<T>toIterable(Object source) Converts the given source object to anIterable.
-
Method Details
-
supportsAwaitable
Returnstrueif this adapter can convert instances of the given type toAwaitable(single-value async result). -
toAwaitable
Converts the given source object to anAwaitable. Called only whensupportsAwaitable(java.lang.Class<?>)returnedtrue. -
supportsIterable
Returnstrueif this adapter can convert instances of the given type to anIterableforfor awaitloops. Defaults tofalse; override for multi-value async types (e.g., ReactorFlux, RxJavaObservable). -
toIterable
Converts the given source object to anIterable. Called only whensupportsIterable(java.lang.Class<?>)returnedtrue. The returned iterable typically blocks onnext()until the next element is available — with virtual threads this is efficient.
-