public class QuickDiagnose extends Object
| Constructor and Description |
|---|
QuickDiagnose() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
diagnosingHackActivated() |
static void |
disableDiagnosingHack()
Disables the optimization hack for
DiagnosingMatcher,
which calls DiagnosingMatcher.matches(java.lang.Object, org.hamcrest.Description)
directly. |
static <T> QuickDiagnosingMatcher<T> |
matcher(org.hamcrest.Matcher<T> matcher) |
static boolean |
matches(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch)
Uses the
matcher to validate item. |
static boolean |
matches(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch,
String message)
Similar to
matches(org.hamcrest.Matcher, java.lang.Object, org.hamcrest.Description),
but allows to override the mismatch message. |
static <T> MatchResult<T> |
matchResult(org.hamcrest.Matcher<?> matcher,
T item) |
public static boolean matches(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch)
matcher to validate item.
If validation fails, an error message is stored in 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 - item was matchedDiagnosingMatcher,
QuickDiagnosingMatcherpublic static boolean matches(org.hamcrest.Matcher<?> matcher,
Object item,
org.hamcrest.Description mismatch,
String message)
matches(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 - public static <T> MatchResult<T> matchResult(org.hamcrest.Matcher<?> matcher, T item)
public static <T> QuickDiagnosingMatcher<T> matcher(org.hamcrest.Matcher<T> matcher)
public static void disableDiagnosingHack()
DiagnosingMatcher,
which calls DiagnosingMatcher.matches(java.lang.Object, org.hamcrest.Description)
directly.
This method has to be invoked before the hack is executed the first time.
IllegalStateException - if the hack was already activated.public static boolean diagnosingHackActivated()
Copyright © 2015. All rights reserved.