GuavaDaoReturnTypeConverter


public final class GuavaDaoReturnTypeConverter


A DaoReturnTypeConverter that allows Room to return ListenableFuture<T> from @Dao functions.

Summary

Public constructors

Public methods

final @NonNull ListenableFuture<@NonNull T>
@DaoReturnTypeConverter(operations = [OperationType.READOperationType.WRITE])
<T extends Object> convertAsync(
    @NonNull RoomDatabase database,
    boolean inTransaction,
    @NonNull SuspendFunction0<@NonNull T> executeAndConvert
)

This convertAsync function will be called from Room generated code to convert a Room query result to the return type of this function.

Public constructors

GuavaDaoReturnTypeConverter

Added in 3.0.0-alpha03
public GuavaDaoReturnTypeConverter()

Public methods

convertAsync

Added in 3.0.0-alpha03
@DaoReturnTypeConverter(operations = [OperationType.READOperationType.WRITE])
public final @NonNull ListenableFuture<@NonNull T> <T extends Object> convertAsync(
    @NonNull RoomDatabase database,
    boolean inTransaction,
    @NonNull SuspendFunction0<@NonNull T> executeAndConvert
)

This convertAsync function will be called from Room generated code to convert a Room query result to the return type of this function.

This converter can be used for both OperationType.READ and OperationType.WRITE. Note that Room shortcut methods (@Insert, @Update, @Delete) are always treated as OperationType.WRITE.

Parameters
@NonNull RoomDatabase database

RoomDatabase instance

boolean inTransaction

True if the DAO is to be executed in a database transaction

@NonNull SuspendFunction0<@NonNull T> executeAndConvert

A suspend lambda function that invokes the part of the generated code that executes the query.