Package: org.apache.groovy.rxjava

## [Java] Class RxJavaAwaitableAdapter

- org.apache.groovy.rxjava.RxJavaAwaitableAdapter

- All Implemented Interfaces and Traits:
    AwaitableAdapter

      public class RxJavaAwaitableAdapter
      extends Object
      implements AwaitableAdapter

  Adapter for RxJava 3 types, enabling:

  - `await single` — awaits a io.reactivex.rxjava3.core.Single
  - `await maybe` — awaits a io.reactivex.rxjava3.core.Maybe (nullable result)
  - `await completable` — awaits a io.reactivex.rxjava3.core.Completable
  - `for await (item in observable)` — iterates over an Observable
  - `for await (item in flowable)` — iterates over a io.reactivex.rxjava3.core.Flowable

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

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `supportsAwaitable(Class<?> type)` Returns whether the supplied type can be awaited as an RxJava single-result source.
    `` | `public boolean` | `supportsIterable(Class<?> type)` Returns whether the supplied type can be exposed as an iterable RxJava multi-result source.
    `<T>` | `public Awaitable<T>` | `toAwaitable(Object source)` Converts supported RxJava single-result sources into an Awaitable.
    `<T>` | `public Iterable<T>` | `toIterable(Object source)` Converts supported RxJava multi-result sources into blocking iterables suitable for `for await` consumption.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

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

      Returns whether the supplied type can be awaited as an RxJava single-result source.

      Parameters:
        `type` - candidate type to inspect
      Returns:
        `true` if `type` is a io.reactivex.rxjava3.core.Single, io.reactivex.rxjava3.core.Maybe, io.reactivex.rxjava3.core.Completable, or one of their subtypes

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

      Returns whether the supplied type can be exposed as an iterable RxJava multi-result source.

      Parameters:
        `type` - candidate type to inspect
      Returns:
        `true` if `type` is an Observable, io.reactivex.rxjava3.core.Flowable, or one of their subtypes

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

      Converts supported RxJava single-result sources into an Awaitable. A io.reactivex.rxjava3.core.Single yields its item, a io.reactivex.rxjava3.core.Maybe yields its item or `null` when empty, and a io.reactivex.rxjava3.core.Completable completes with `null`.

      throws:
        IllegalArgumentException if `source` is not a supported RxJava type
      Parameters:
        `source` - source object to adapt
      Type Parameters:
        `T` - awaited value type
      Returns:
        awaitable representation of the supplied source

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

      Converts supported RxJava multi-result sources into blocking iterables suitable for `for await` consumption.

      throws:
        IllegalArgumentException if `source` is not a supported RxJava type
      Parameters:
        `source` - source object to adapt
      Type Parameters:
        `T` - iterated element type
      Returns:
        iterable representation of the supplied Observable or io.reactivex.rxjava3.core.Flowable