public class CombinableMatcher<T> extends BaseMatcher<T>
Constructor and Description |
---|
CombinableMatcher(Matcher<? super T> matcher) |
Modifier and Type | Method and Description |
---|---|
CombinableMatcher<T> |
and(Matcher<? super T> other) |
static <LHS> CombinableMatcher<LHS> |
both(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers that must both pass.
|
void |
describeTo(Description description)
Generates a description of the object.
|
static <LHS> CombinableMatcher<LHS> |
either(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers where either may pass, for example:
|
boolean |
matches(Object item)
Evaluates the matcher for argument item.
|
CombinableMatcher<T> |
or(Matcher<? super T> other) |
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, toString
public boolean matches(Object item)
Matcher
This method matches against Object, instead of the generic type T. This is because the caller of the Matcher does not know at runtime what the type is (because of type erasure with Java generics). It is down to the implementations to check the correct type.
item
- the object against which the matcher is evaluated.true
if item matches, otherwise false
.BaseMatcher
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.public CombinableMatcher<T> and(Matcher<? super T> other)
public CombinableMatcher<T> or(Matcher<? super T> other)
public static <LHS> CombinableMatcher<LHS> both(Matcher<? super LHS> matcher)
assertThat(string, both(containsString("a")).and(containsString("b")));
public static <LHS> CombinableMatcher<LHS> either(Matcher<? super LHS> matcher)
assertThat(string, both(containsString("a")).and(containsString("b")));
Copyright © 2016. All rights reserved.