# CharSequenceTransformation.Builder

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/service/autofill/CharSequenceTransformation.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                             ||
| ↳ | [android.service.autofill.CharSequenceTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#) |

Builder for[CharSequenceTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation)objects.

## Summary

|                                                                                                                                                                                                                                                                                                                  Public constructors                                                                                                                                                                                                                                                                                                                  ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#Builder(android.view.autofill.AutofillId,%20java.util.regex.Pattern,%20kotlin.String))`(`id:` `[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)`, `regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `subst:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Creates a new builder and adds the first transformed contents of a field to the overall result of this transformation. |

|                                                                                                                                                                                                                                                                                                                                                                                Public methods                                                                                                                                                                                                                                                                                                                                                                                ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[CharSequenceTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#)! | [addField](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#addField(android.view.autofill.AutofillId,%20java.util.regex.Pattern,%20kotlin.String))`(`id:` `[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)`, `regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `subst:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Adds the transformed contents of a field to the overall result of this transformation. |
| open[CharSequenceTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation)!                  | [build](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#build())`()` Creates a new[CharSequenceTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation)instance.                                                                                                                                                                                                                                                                                                                               |

## Public constructors

### Builder

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    id: AutofillId, 
    regex: Pattern, 
    subst: String)
```

Creates a new builder and adds the first transformed contents of a field to the overall result of this transformation.

|                                                                                                                   Parameters                                                                                                                    ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`    | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#):id of the screen field. This value cannot be`null`.                                                                                |
| `regex` | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression with groups (delimited by`(`and`(`) that are used to substitute parts of the value. This value cannot be`null`.             |
| `subst` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the string that substitutes the matched regex, using`$`for group substitution (`$1`for 1st group match,`$2`for 2nd, etc). This value cannot be`null`. |

## Public methods

### addField

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun addField(
    id: AutofillId, 
    regex: Pattern, 
    subst: String
): CharSequenceTransformation.Builder!
```

Adds the transformed contents of a field to the overall result of this transformation.

|                                                                                                                   Parameters                                                                                                                    ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`    | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#):id of the screen field. This value cannot be`null`.                                                                                |
| `regex` | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression with groups (delimited by`(`and`(`) that are used to substitute parts of the value. This value cannot be`null`.             |
| `subst` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the string that substitutes the matched regex, using`$`for group substitution (`$1`for 1st group match,`$2`for 2nd, etc). This value cannot be`null`. |

|                                                                              Return                                                                               ||
|----------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| [CharSequenceTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation.Builder#)! | this builder. |

### build

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun build(): CharSequenceTransformation!
```

Creates a new[CharSequenceTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/CharSequenceTransformation)instance.