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 |
Summary
Public methods |
|
|---|---|
abstract @NonNull T |
@ExperimentalAppSearchApiConverts a |
abstract @NonNull List<Class<Object>> |
Returns document classes that this document class depends on. |
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 |
toGenericDocument(@NonNull T document)Converts an instance of the class annotated with \@ |
Public methods
fromGenericDocument
@ExperimentalAppSearchApi
abstract @NonNull T fromGenericDocument(
@NonNull GenericDocument genericDoc,
@NonNull DocumentClassMappingContext documentClassMappingContext
)
Converts a androidx.appsearch.app.GenericDocument into an instance of the document class. For nested document properties, this method should pass documentClassMappingContext down to the nested calls of toDocumentClass.
| Parameters | |
|---|---|
@NonNull GenericDocument genericDoc |
The document to convert. |
@NonNull DocumentClassMappingContext documentClassMappingContext |
The context object that holds mapping information for document classes and their parent types. This context typically comes from |
getDependencyDocumentClasses
abstract @NonNull List<Class<Object>> getDependencyDocumentClasses()
Returns document classes that this document class depends on. This is useful so clients are not required to explicitly set all dependencies.
getSchema
abstract @NonNull AppSearchSchema getSchema()
Returns the schema for this document class.
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.