Class

SubspaceSemanticsMatcher

Wrapper for semantics matcher lambdas that allows building a description string explaining to the developer what conditions were being tested.

Source set: Android
public class SubspaceSemanticsMatcher(
    public val description: String,
    private val matcher: (SubspaceSemanticsInfo) -> Boolean,
)

Wrapper for semantics matcher lambdas that allows building a description string explaining to the developer what conditions were being tested.

This class encapsulates a predicate that evaluates a SubspaceSemanticsInfo node to verify whether it matches the expected semantic properties. It is primarily used by the testing framework to locate nodes within a Subspace hierarchy.

Parameters

description A human-readable explanation of the condition being tested, used in test failure messages.
matcher The predicate function that evaluates a given SubspaceSemanticsInfo.

Functions

matches

Source set: Android
public fun matches(node: SubspaceSemanticsInfo): Boolean

Returns whether the given node is matched by this matcher.

Parameters

node The target SubspaceSemanticsInfo to evaluate.

Return

true if the node satisfies the predicate; false otherwise.

matchesAny

Source set: Android
public fun matchesAny(nodes: Iterable<SubspaceSemanticsInfo>): Boolean

Returns whether at least one of the given nodes is matched by this matcher.

Edge Cases: If the provided nodes iterable is empty, this evaluation returns false.

Parameters

nodes An iterable collection of SubspaceSemanticsInfo instances to evaluate.

Return

true if at least one node satisfies the predicate; false otherwise.

and

Source set: Android
public infix fun and(other: SubspaceSemanticsMatcher): SubspaceSemanticsMatcher

Combines this matcher with other using a short-circuiting logical AND.

The resulting matcher evaluates to true only if both this and the other matcher succeed on a given node.

Parameters

other The second SubspaceSemanticsMatcher to satisfy.

Return

A combined SubspaceSemanticsMatcher.

or

Source set: Android
public infix fun or(other: SubspaceSemanticsMatcher): SubspaceSemanticsMatcher

Combines this matcher with other using a short-circuiting logical OR.

The resulting matcher evaluates to true if either this or the other matcher succeeds on a given node.

Parameters

other The alternative SubspaceSemanticsMatcher to satisfy.

Return

A combined SubspaceSemanticsMatcher.

not

Source set: Android
public operator fun not(): SubspaceSemanticsMatcher

Inverts the evaluation logic of this matcher using a logical NOT.

Evaluates to true if the underlying matcher evaluates to false.

Return

A negated SubspaceSemanticsMatcher.

Members

Companion

Source set: Android
public companion object

Functions

expectValue

Source set: Android
public fun <T> expectValue(
            key: SemanticsPropertyKey<T>,
            expectedValue: T,
        ): SubspaceSemanticsMatcher

Builds a predicate that tests whether the value of the given key is equal to expectedValue.

Nullability & Edge Cases: If the key is not present in a node's semantics configuration, the comparison evaluates whether null == expectedValue. Therefore, passing null as the expectedValue successfully matches nodes where the key is entirely omitted, as well as nodes where the key is present but has a value of null.

Parameters

key The SemanticsPropertyKey to look up in the node's configuration.
expectedValue The expected property value to verify against.

Return

A SubspaceSemanticsMatcher for the specified key-value condition.

keyIsDefined

Source set: Android
public fun <T> keyIsDefined(key: SemanticsPropertyKey<T>): SubspaceSemanticsMatcher

Builds a predicate that tests whether the given key is defined in semantics.

Edge Cases: This check simply verifies the pre-existence of the key mapping in the node's configuration regardless of its underlying assigned value.

Parameters

key The SemanticsPropertyKey to inspect.

Return

A SubspaceSemanticsMatcher verifying the presence of the key.

keyNotDefined

Source set: Android
public fun <T> keyNotDefined(key: SemanticsPropertyKey<T>): SubspaceSemanticsMatcher

Builds a predicate that tests whether the given key is NOT defined in semantics.

Edge Cases: This check validates that the key mapping is completely absent from the node's configuration.

Parameters

key The SemanticsPropertyKey to inspect.

Return

A SubspaceSemanticsMatcher verifying the absence of the key.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: