Stay organized with collections
Save and categorize content based on your preferences.
@Documented
@Retention(value = RetentionPolicy.CLASS)
@Target(value = [ElementType.METHOD, ElementType.TYPE])
public annotation Document.BuilderProducer
Marks a static method or a builder class directly as a builder producer. A builder class should contain a "build()" method to construct the AppSearch document object and setter methods to set field values.
When a static method is marked as a builder producer, the method should return a builder instance for AppSearch to construct the document object. When a builder class is marked as a builder producer directly, AppSearch will use the constructor of the builder class to create a builder instance.
The annotated static method or the constructor of the annotated builder class is allowed to accept parameters to set a part of field values. In this case, AppSearch will only use setters to set values for the remaining fields.
Once a builder producer is specified, AppSearch will be forced to use the builder pattern to construct the document object.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-07-17 UTC.
[null,null,["Last updated 2025-07-17 UTC."],[],[],null,["# Document.BuilderProducer\n========================\n\nArtifact: [androidx.appsearch:appsearch](/jetpack/androidx/releases/appsearch) \n[View Source](https://cs.android.com/search?q=file:androidx/appsearch/annotation/Document.java+class:androidx.appsearch.annotation.Document.BuilderProducer) \nAdded in [1.1.0](/jetpack/androidx/releases/appsearch#1.1.0)\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/androidx/appsearch/annotation/Document.BuilderProducer \"View this page in Kotlin\") \\|Java\n\n\n```\n@Documented\n@Retention(value = RetentionPolicy.CLASS)\n@Target(value = [ElementType.METHOD, ElementType.TYPE])\npublic annotation Document.BuilderProducer\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nMarks a static method or a builder class directly as a builder producer. A builder class should contain a \"build()\" method to construct the AppSearch document object and setter methods to set field values.\n\nWhen a static method is marked as a builder producer, the method should return a builder instance for AppSearch to construct the document object. When a builder class is marked as a builder producer directly, AppSearch will use the constructor of the builder class to create a builder instance.\n\nThe annotated static method or the constructor of the annotated builder class is allowed to accept parameters to set a part of field values. In this case, AppSearch will only use setters to set values for the remaining fields.\n\nOnce a builder producer is specified, AppSearch will be forced to use the builder pattern to construct the document object."]]