T - public abstract class QuickDiagnosingMatcherBase<T> extends org.hamcrest.BaseMatcher<T> implements QuickDiagnosingMatcher<T>
QuickDiagnosingMatcher implementations should extend this class,
or QuickMatcherBase.
Only matches(java.lang.Object, org.hamcrest.Description) has to be implemented.
Has some abstract subclasses that provide a more features for matcher implementations. Each also has a typesafe variant.
| Constructor and Description |
|---|
QuickDiagnosingMatcherBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
describeMismatch(Object item,
org.hamcrest.Description description) |
boolean |
matches(Object o) |
abstract boolean |
matches(Object item,
org.hamcrest.Description mismatch)
Evaluates the matcher for argument
item. |
<I> MatchResult<I> |
matchResult(I item)
Returns a
MatchResult that caches the mismatch descripton. |
protected static boolean |
quickMatch(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch)
Uses the
matcher to validate item. |
protected static boolean |
quickMatch(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch,
String message)
Similar to
quickMatch(org.hamcrest.Matcher, java.lang.Object, org.hamcrest.Description),
but allows to override the mismatch message. |
protected static <T> MatchResult<T> |
quickMatchResult(org.hamcrest.Matcher<?> matcher,
T item) |
_dont_implement_Matcher___instead_extend_BaseMatcher_, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic void describeMismatch(Object item, org.hamcrest.Description description)
public abstract boolean matches(Object item, org.hamcrest.Description mismatch)
item.
A mismatch description is appended to mismatch
if and only if the match fails.
matches in interface QuickDiagnosingMatcher<T>item - The object against which the matcher is evaluated.mismatch - The description to be built or appended to.true if item matches, otherwise false.public <I> MatchResult<I> matchResult(I item)
MatchResult that caches the mismatch descripton.matchResult in interface QuickDiagnosingMatcher<T>I - item - protected static boolean quickMatch(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch)
matcher to validate item.
If validation fails, an error message is appended to mismatch.
The code is equivalent to
if (matcher.matches(item)) {
return true;
} else {
matcher.describeMismatch(item, mismatch);
return false;
}
but uses optimizations for diagnosing matchers.matcher - item - mismatch - true iif item was matchedDiagnosingMatcher,
QuickDiagnosingMatcherprotected static boolean quickMatch(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch,
String message)
quickMatch(org.hamcrest.Matcher, java.lang.Object, org.hamcrest.Description),
but allows to override the mismatch message.
If matching fails, message will be appended to mismatch.
Any occurrence of "$1" in (@code message} will be replaced with
the actual mismatch description of matcher.
matcher - item - mismatch - message - true iif item was matchedprotected static <T> MatchResult<T> quickMatchResult(org.hamcrest.Matcher<?> matcher, T item)
Copyright © 2015. All rights reserved.