Rule

sealed class Rule<T> : DataItemConvertible

Simple Rule builder class for building out logical rules, that can be serialized to a DataItem The type of T should therefore either implement DataItemConvertible or be one of the types supported by DataItem

The type T is the required input type, e.g. Condition for complex rules or String for

Types

Link copied to clipboard
object Companion
Link copied to clipboard

DataItemConverter implementation that handles the re-creation of the Rule operators, delegating the creation of the T to the provided converter.

Functions

Link copied to clipboard
fun and(vararg others: Rule<T>): Rule<T>

Returns a new Rule that is the logical equivalent of the following operation:

Link copied to clipboard
abstract fun asDataItem(): DataItem

Should return an instance of a DataItem that represents all required properties of the implementing class, such that it could be:

Link copied to clipboard
fun <R> asMatchable(converter: (T) -> Matchable<R>): Matchable<R>

Takes a Rule implementation and converts it another Rule, wrapping the type of T in a Matchable so it can be evaluated.

Link copied to clipboard

Convenience method to convert a Rule to a Matchable

Link copied to clipboard
fun <T : Matchable<R>, R> Rule<T>.matches(input: R): Boolean

Convenience method to determine if a Rule is satisfied by the given input.

Link copied to clipboard
fun not(): Rule<T>

Returns a new Rule that is the logical equivalent of the following operation:

Link copied to clipboard
fun or(vararg others: Rule<T>): Rule<T>

Returns a new Rule that is the logical equivalent of the following: