Stay organized with collections Save and categorize content based on your preferences.

DocumentClassFactory

public 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 methods

abstract @NonNull T

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

abstract @NonNull AppSearchSchema

Returns the schema for this document class.

abstract @NonNull String

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

abstract @NonNull GenericDocument

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

Public methods

fromGenericDocument

abstract @NonNullfromGenericDocument(@NonNull GenericDocument genericDoc)

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

Throws
androidx.appsearch.exceptions.AppSearchException androidx.appsearch.exceptions.AppSearchException

getSchema

abstract @NonNull AppSearchSchema getSchema()

Returns the schema for this document class.

Throws
androidx.appsearch.exceptions.AppSearchException androidx.appsearch.exceptions.AppSearchException

getSchemaName

abstract @NonNull String getSchemaName()

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

This is the name used in queries for type restricts.

toGenericDocument

abstract @NonNull GenericDocument toGenericDocument(@NonNull T document)

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

Throws
androidx.appsearch.exceptions.AppSearchException androidx.appsearch.exceptions.AppSearchException