CaseMatch

sealed interface CaseMatch<out Value>

The exact outcome of attempting to match a CaseKeyPath against a root value.

Inheritors

Types

Link copied to clipboard
data class Matched<out Value>(val value: Value) : CaseMatch<Value>

The root matched, including when value itself is null.

Link copied to clipboard
data object NoMatch : CaseMatch<Nothing>

The root was not the case represented by this CaseKeyPath.

Properties

Link copied to clipboard

Intentionally collapses CaseMatch.NoMatch and CaseMatch.Matched with a null value.

Functions

Link copied to clipboard

Chains a second match operation only after this result matched.

Link copied to clipboard
inline fun <Value, Result> CaseMatch<Value>.fold(onNoMatch: () -> Result, onMatched: (Value) -> Result): Result

Folds the exact matching result into an arbitrary value.

Link copied to clipboard

Kotlin-style function spelling of valueOrNull.

Link copied to clipboard
inline fun <Value, NewValue> CaseMatch<Value>.map(transform: (Value) -> NewValue): CaseMatch<NewValue>

Transforms a matched value while retaining an unmatched result.

Link copied to clipboard

Intentionally treats a matched null value as another nonmatch.