# LayoutElementMatcher

Artifact: [androidx.wear.protolayout:protolayout-testing](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/testing/LayoutElementMatcher.kt+class:androidx.wear.protolayout.testing.LayoutElementMatcher) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

*** ** * ** ***


```
public final class LayoutElementMatcher
```

<br />

*** ** * ** ***

Wrapper for element matcher lambdas that allows to build string explaining to the developer what conditions are being tested.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher#LayoutElementMatcher(kotlin.String,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> matcher )` Constructor for the Wrapper of element matcher lambdas that allows to build string explaining to the developer what conditions are being tested. |
| `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher#LayoutElementMatcher(kotlin.String,kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/TestContext, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> matcher )` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher#and(androidx.wear.protolayout.testing.LayoutElementMatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher other)` Returns whether the given element is matched by both this and the other mather. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher#not()()` Returns whether the given element does not match the matcher. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher#or(androidx.wear.protolayout.testing.LayoutElementMatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher other)` Returns whether the given element is matched by this or the other mather. |

## Public constructors

### LayoutElementMatcher

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public LayoutElementMatcher(
    @NonNull String description,
    @NonNull Function1<@NonNull LayoutElementBuilders.LayoutElement, @NonNull Boolean> matcher
)
```

Constructor for the Wrapper of element matcher lambdas that allows to build string explaining to the developer what conditions are being tested.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description` | a string explaining to the developer what conditions were being tested. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> matcher` | a lambda performing the actual logic of matching on the layout element. |

### LayoutElementMatcher

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public LayoutElementMatcher(
    @NonNull String description,
    @NonNull Function2<@NonNull LayoutElementBuilders.LayoutElement, @NonNull TestContext, @NonNull Boolean> matcher
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description` | a string explaining to the developer what conditions were being tested. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/TestContext, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> matcher` | a lambda performing the actual logic of matching on the layout element, with a TextContext accessible for retrieving context data such as the dynamic data map for evaluating the dynamic values. |

## Public methods

### and

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementMatcher and(@NonNull LayoutElementMatcher other)
```

Returns whether the given element is matched by both this and the other mather.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher other` | mather that should also match in addition to current matcher. |

### not

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementMatcher not()
```

Returns whether the given element does not match the matcher.

### or

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementMatcher or(@NonNull LayoutElementMatcher other)
```

Returns whether the given element is matched by this or the other mather.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher other` | mather that can be tested to match if the current matcher does not. |