T
- The type of the matched entity.@HashCodeAndEqualsPlugin.Enhance public class FailSafeMatcher<T> extends ElementMatcher.Junction.AbstractBase<T>
ElementMatcher.Junction.AbstractBase<V>, ElementMatcher.Junction.Conjunction<W>, ElementMatcher.Junction.Disjunction<W>
ElementMatcher.Junction<S>
Modifier and Type | Field and Description |
---|---|
private boolean |
fallback
The fallback value in case of an exception.
|
private ElementMatcher<? super T> |
matcher
The delegate matcher that might throw an exception.
|
Constructor and Description |
---|
FailSafeMatcher(ElementMatcher<? super T> matcher,
boolean fallback)
Creates a new fail-safe element matcher.
|
Modifier and Type | Method and Description |
---|---|
boolean |
matches(T target)
Matches a target against this element matcher.
|
java.lang.String |
toString() |
and, or
private final ElementMatcher<? super T> matcher
private final boolean fallback
public FailSafeMatcher(ElementMatcher<? super T> matcher, boolean fallback)
matcher
- The delegate matcher that might throw an exception.fallback
- The fallback value in case of an exception.public boolean matches(T target)
target
- The instance to be matched.true
if the given element is matched by this matcher or false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object