UserData.Builder

public static final class UserData.Builder
extends Object

java.lang.Object
   ↳ android.service.autofill.UserData.Builder


A builder for UserData objects.

Summary

Public constructors

UserData.Builder(String id, String value, String categoryId)

Creates a new builder for the user data used for field classification.

Public methods

UserData.Builder add(String value, String categoryId)

Adds a new value for user data.

UserData build()

Creates a new UserData instance.

UserData.Builder setFieldClassificationAlgorithm(String name, Bundle args)

Sets the algorithm used for field classification.

Inherited methods

Public constructors

UserData.Builder

UserData.Builder (String id, 
                String value, 
                String categoryId)

Creates a new builder for the user data used for field classification.

The user data must contain at least one pair of value -> categoryId, and more pairs can be added through the add(String, String) method. For example:

 new UserData.Builder("v1", "Bart Simpson", "name")
   .add("bart.simpson@example.com", "email")
   .add("el_barto@example.com", "email")
   .build();
 

Parameters
id String: id used to identify the whole UserData object. This id is also returned by getUserDataId(), which can be used to check if the UserData is up-to-date without fetching the whole object (through getUserData()).

This value must never be null.

value String: value of the user data.

This value must never be null.

categoryId String: string used to identify the category the value is associated with.

This value must never be null.

Throws
IllegalArgumentException if any of the following occurs:

Public methods

add

UserData.Builder add (String value, 
                String categoryId)

Adds a new value for user data.

Parameters
value String: value of the user data.

This value must never be null.

categoryId String: string used to identify the category the value is associated with.

This value must never be null.

Returns
UserData.Builder

Throws
IllegalStateException if:
IllegalArgumentException if any of the following occurs:

build

UserData build ()

Creates a new UserData instance.

You should not interact with this builder once this method is called.

Returns
UserData The built dataset.

Throws
IllegalStateException if build() was already called.

setFieldClassificationAlgorithm

UserData.Builder setFieldClassificationAlgorithm (String name, 
                Bundle args)

Sets the algorithm used for field classification.

The currently available algorithms can be retrieve through getAvailableFieldClassificationAlgorithms().

If not set, the default algorithm is used instead.

Parameters
name String: name of the algorithm or null to used default.

args Bundle: optional arguments to the algorithm.

This value may be null.

Returns
UserData.Builder this builder