DaoReturnTypeConverters


@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CLASS, AnnotationTarget.PROPERTY_GETTER])
@Retention(value = AnnotationRetention.BINARY)
public annotation DaoReturnTypeConverters


Specifies the classes that contain DAO return type converters that a RoomDatabase can use.

This annotation is used to register converter classes that contain methods annotated with DaoReturnTypeConverter via annotating a Database, Dao, or Dao function.

All Dao methods in the annotated scope will be able to use the converters. These converters allow you to wrap or transform the result of a DAO method into a custom Kotlin return type (e.g., Result<MyEntity>, Result<List<MyEntity>>).

Converters in inner scopes override matching converters in outer scopes (for example, a Dao converter overrides a Database converter, and a Dao function converter overrides a Dao converter). Defining duplicate converters within the same scope is not allowed.

Important Distinction from ColumnTypeConverters:

Unlike ColumnTypeConverters, which convert any query result column to be converted to a field/property regardless if the field or property is on an entity or a data object class for storage, DaoReturnTypeConverters only applies to the return value of a DAO method. They are designed specifically to intercept the return value of a query or the result of a write operation.

Summary

Public methods

final @NonNull KClass[]

The list of DAO return type converter classes.

Public methods

getValue

public final @NonNull KClass[] getValue()

The list of DAO return type converter classes. If converter methods are not static, Room will create an instance of these classes.

Returns
@NonNull KClass[]

The list of classes that contains the converter methods.