> Documentation index: https://developer.android.com/reference/llms.txt

# AppFunctionPatternMatcher

Artifact: [androidx.appfunctions:appfunctions](https://developer.android.com/jetpack/androidx/releases/appfunctions.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/appfunctions/AppFunctionPatternMatcher.kt+class:androidx.appfunctions.AppFunctionPatternMatcher) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/appfunctions.md.txt#1.0.0)

*** ** * ** ***


```
@Retention(value = AnnotationRetention.BINARY)
@Target
annotation AppFunctionPatternMatcher
```

<br />

*** ** * ** ***

Declares a `android.os.PatternMatcher` that string values can match, used in `AppFunctionStringValueConstraint.patternMatchers`.

When multiple matchers are declared, a value is valid if it matches any of them (logical OR).

The arguments mirror the `android.os.PatternMatcher` constructor and are translated into one at compile time.

### Usage Example:

```kotlin
// Accepts values that start with "acct_" OR consist only of digits.
@AppFunctionDeclaration(isDescribedByKDoc = false)
fun setAccountId(
    @AppFunctionStringValueConstraint(
        patternMatchers = [
            AppFunctionPatternMatcher("acct_", PatternMatcher.PATTERN_PREFIX),
            AppFunctionPatternMatcher("[0-9]+", PatternMatcher.PATTERN_ADVANCED_GLOB),
        ]
    )
    accountId: String
) {
    // Function body
}
```

## Summary

| ### Public constructors |
|---|
| `AppFunctionPatternMatcher(pattern: String, type: Int)` |

| ### Public properties |
|---|---|
| `String` | `pattern` The pattern string, as passed to `android.os.PatternMatcher`. |
| `Int` | `type` The pattern type: one of the `android.os.PatternMatcher.PATTERN_*` constants, such as `android.os.PatternMatcher.PATTERN_PREFIX` or `android.os.PatternMatcher.PATTERN_ADVANCED_GLOB`. |

## Public constructors

### AppFunctionPatternMatcher

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/appfunctions.md.txt#1.0.0)

```
AppFunctionPatternMatcher(pattern: String, type: Int)
```

## Public properties

### pattern

```
val pattern: String
```

The pattern string, as passed to `android.os.PatternMatcher`.

The pattern is not validated at compile time. If `android.os.PatternMatcher` rejects it (for example, a malformed `android.os.PatternMatcher.PATTERN_ADVANCED_GLOB`), the function using it is omitted from agents' search results. If the pattern is on a property of an `AppFunctionSerializable`, all of the app's functions are omitted.

### type

```
val type: Int
```

The pattern type: one of the `android.os.PatternMatcher.PATTERN_*` constants, such as `android.os.PatternMatcher.PATTERN_PREFIX` or `android.os.PatternMatcher.PATTERN_ADVANCED_GLOB`.

The type is interpreted by `android.os.PatternMatcher` on the device, so a type that the device's SDK does not support matches no values.