DocumentClassFactory


interface DocumentClassFactory<T>


An interface for factories which can convert between instances of classes annotated with \@androidx.appsearch.annotation.Document and instances of GenericDocument.

Parameters
<T>

The document class type this factory converts to and from GenericDocument.

Summary

Public functions

T
fromGenericDocument(
    genericDoc: GenericDocument,
    documentClassMap: (Mutable)Map<String!, (Mutable)List<String!>!>?
)

Converts a androidx.appsearch.app.GenericDocument into an instance of the document class.

(Mutable)List<Class<Any!>!>

Returns document classes that this document class depends on.

AppSearchSchema

Returns the schema for this document class.

String

Returns the name of this schema type, e.g.

GenericDocument
toGenericDocument(document: T)

Converts an instance of the class annotated with \@androidx.appsearch.annotation.Document into a androidx.appsearch.app.GenericDocument.

Public functions

fromGenericDocument

Added in 1.1.0-alpha06
fun fromGenericDocument(
    genericDoc: GenericDocument,
    documentClassMap: (Mutable)Map<String!, (Mutable)List<String!>!>?
): T

Converts a androidx.appsearch.app.GenericDocument into an instance of the document class. For nested document properties, this method should pass documentClassMap down to the nested calls of toDocumentClass.

getDependencyDocumentClasses

Added in 1.1.0-alpha06
fun getDependencyDocumentClasses(): (Mutable)List<Class<Any!>!>

Returns document classes that this document class depends on. This is useful so clients are not required to explicitly set all dependencies.

getSchema

Added in 1.1.0-alpha06
fun getSchema(): AppSearchSchema

Returns the schema for this document class.

getSchemaName

Added in 1.1.0-alpha06
fun getSchemaName(): String

Returns the name of this schema type, e.g. Email.

This is the name used in queries for type restricts.

toGenericDocument

Added in 1.1.0-alpha06
fun toGenericDocument(document: T): GenericDocument

Converts an instance of the class annotated with \@androidx.appsearch.annotation.Document into a androidx.appsearch.app.GenericDocument.