DocumentClassFactory

public interface DocumentClassFactory

androidx.appsearch.app.DocumentClassFactory<T>


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

Summary

Public methods

abstract T fromGenericDocument(GenericDocument genericDoc)

Converts a GenericDocument into an instance of the document class.

abstract AppSearchSchema getSchema()

Returns the schema for this document class.

abstract String getSchemaName()

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

abstract GenericDocument toGenericDocument(T document)

Converts an instance of the class annotated with \@Document into a GenericDocument.

Public methods

fromGenericDocument

public abstract T fromGenericDocument (GenericDocument genericDoc)

Converts a GenericDocument into an instance of the document class.

Parameters
genericDoc GenericDocument

Returns
T

Throws
AppSearchException

getSchema

public abstract AppSearchSchema getSchema ()

Returns the schema for this document class.

Returns
AppSearchSchema

Throws
AppSearchException

getSchemaName

public abstract String getSchemaName ()

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

This is the name used in queries for type restricts.

Returns
String

toGenericDocument

public abstract GenericDocument toGenericDocument (T document)

Converts an instance of the class annotated with \@Document into a GenericDocument.

Parameters
document T

Returns
GenericDocument

Throws
AppSearchException