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
public fun matches(node: SubspaceSemanticsInfo): Boolean
Returns whether the given node is matched by this matcher.
Parameters
| node | The target SubspaceSemanticsInfo to evaluate. |
Returns
true if the node satisfies the predicate; false otherwise. |
matchesAny
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. |
Returns
true if at least one node satisfies the predicate; false otherwise. |
and
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. |
Returns
| A combined SubspaceSemanticsMatcher. |
or
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. |
Returns
| A combined SubspaceSemanticsMatcher. |
not
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.
Returns
| A negated SubspaceSemanticsMatcher. |
Companion Object
Methods
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. |
Returns
| A SubspaceSemanticsMatcher for the specified key-value condition. |
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. |
Returns
| A SubspaceSemanticsMatcher verifying the presence of the key. |
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. |
Returns
| A SubspaceSemanticsMatcher verifying the absence of the key. |