SingleItemContextMatcher

Companion:
class
class Object
trait Matchable
class Any

Type members

Classlikes

case class And[Item, A, B, R](left: SingleItemContextMatcher[Item, A], right: SingleItemContextMatcher[Item, B])(implicit reduce: Aux[A, B, R]) extends SingleItemContextMatcher[Item, R]

Combines two SingleElementContextMatchers such that the resulting matcher will succeed if both the right and left matchers succeed, and returns the results of both matchers (as a tuple, but reduced via the TypeReduce rules)

Combines two SingleElementContextMatchers such that the resulting matcher will succeed if both the right and left matchers succeed, and returns the results of both matchers (as a tuple, but reduced via the TypeReduce rules)

Type parameters:
A

The left matcher's context type

B

The right matcher's context type

R

The type reduction of (A, B)

Value parameters:
left

The left matcher, with a context type of A

reduce

The TypeReduce rule

right

The right matcher, with a context type of B

class Default[Item, A](f: Item => Option[A]) extends SingleItemContextMatcher[Item, A]

SingleElementContextMatcher that delegates to the given function f to perform its match.

SingleElementContextMatcher that delegates to the given function f to perform its match.

Type parameters:
A

The matched context type

Value parameters:
f

A function that performs the context match on a single element

case class Mapped[Item, A, B](inner: SingleItemContextMatcher[Item, A], op: String)(f: A => Option[B]) extends SingleItemContextMatcher[Item, B]

Similar to ContextMatcher.Mapped, but specialized for SingleElementContextMatcher

Similar to ContextMatcher.Mapped, but specialized for SingleElementContextMatcher

case class Or[Item, A](left: SingleItemContextMatcher[Item, A], right: SingleItemContextMatcher[Item, A]) extends SingleItemContextMatcher[Item, A]

Similar to ContextMatcher.Or, but specialized for SingleElementContextMatcher

Similar to ContextMatcher.Or, but specialized for SingleElementContextMatcher

class Predicate[Item](f: Item => Boolean) extends SingleItemContextMatcher[Item, Unit]

SingleElementContextMatcher that successfully matches (with no result) if the given predicate function returns true for the matched element.

SingleElementContextMatcher that successfully matches (with no result) if the given predicate function returns true for the matched element.

Value parameters:
f

The predicate function

Value members

Concrete methods

def apply[Item, A](f: Item => Option[A]): SingleItemContextMatcher[Item, A]

Create a new single-element matcher which calls the given matcher function f on the first element of the stack. If f returns None, the match fails, otherwise, the match succeeds.

Create a new single-element matcher which calls the given matcher function f on the first element of the stack. If f returns None, the match fails, otherwise, the match succeeds.

Type parameters:
A

The match result type

Value parameters:
f

The matcher function

Returns:

A new single-element matcher which applies f to the stack head

def apply[Item, A](name: String, f: Item => Option[A]): SingleItemContextMatcher[Item, A]

Create a new single-element matcher which calls the given matcher function f on the first element of the stack. If f returns None, the match fails, otherwise, the match succeeds.

Create a new single-element matcher which calls the given matcher function f on the first element of the stack. If f returns None, the match fails, otherwise, the match succeeds.

Type parameters:
A

The match result type

Value parameters:
f

The matcher function

name

This value will be used as the matcher's toString

Returns:

A new single-element matcher which applies f to the stack head

def predicate[Item](f: Item => Boolean): SingleItemContextMatcher[Item, Unit]

Create a new single-element matcher which calls the given predicate function f on the first element of the stack. If f returns true, the match succeeds. Otherwise, the match fails.

Create a new single-element matcher which calls the given predicate function f on the first element of the stack. If f returns true, the match succeeds. Otherwise, the match fails.

Value parameters:
f

The predicate function

Returns:

A new single-element matcher which uses f to determine a match

def predicate[Item](name: String, f: Item => Boolean): SingleItemContextMatcher[Item, Unit]

Create a new single-element matcher which calls the given predicate function f on the first element of the stack. If f returns true, the match succeeds. Otherwise, the match fails.

Create a new single-element matcher which calls the given predicate function f on the first element of the stack. If f returns true, the match succeeds. Otherwise, the match fails.

Value parameters:
f

The predicate function

name

This value will be used as the matcher's toString

Returns:

A new single-element matcher which uses f to determine a match