# AppFunctionPatternMatcher

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

*** ** * ** ***


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

<br />

*** ** * ** ***

Declares a `https://developer.android.com/reference/android/os/PatternMatcher.html` that string values can match, used in `https://developer.android.com/reference/androidx/appfunctions/AppFunctionStringValueConstraint#patternMatchers()`.

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

The arguments mirror the `https://developer.android.com/reference/android/os/PatternMatcher.html` constructor and are translated into one at compile time.

### Usage Example:

```
// 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 methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/AppFunctionPatternMatcher#getPattern()()` The pattern string, as passed to `https://developer.android.com/reference/android/os/PatternMatcher.html`. |
| `final int` | `https://developer.android.com/reference/androidx/appfunctions/AppFunctionPatternMatcher#getType()()` The pattern type: one of the `android.os.PatternMatcher.PATTERN_*` constants, such as `https://developer.android.com/reference/android/os/PatternMatcher.html#PATTERN_PREFIX` or `https://developer.android.com/reference/android/os/PatternMatcher.html#PATTERN_ADVANCED_GLOB`. |

## Public methods

### getPattern

```
public final @NonNull String getPattern()
```

The pattern string, as passed to `https://developer.android.com/reference/android/os/PatternMatcher.html`.

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

### getType

```
public final int getType()
```

The pattern type: one of the `android.os.PatternMatcher.PATTERN_*` constants, such as `https://developer.android.com/reference/android/os/PatternMatcher.html#PATTERN_PREFIX` or `https://developer.android.com/reference/android/os/PatternMatcher.html#PATTERN_ADVANCED_GLOB`.

The type is interpreted by `https://developer.android.com/reference/android/os/PatternMatcher.html` on the device, so a type that the device's SDK does not support matches no values.