public class FunctionalMatcher<T>
extends org.hamcrest.BaseMatcher<T>
Class allows to create instances of the Matcher
using functional interfaces to delegate actual functionality.
Three components are required to create a matcher:
| Constructor and Description |
|---|
FunctionalMatcher(java.lang.Class<? super T> type,
java.util.function.Predicate<T> predicate,
java.util.function.Consumer<org.hamcrest.Description> describer)
To create an instance of the functional matcher you have to specify a
Class of items,
for Hamcrest's matchers don't perform any basic type assertion; a Predicate of the same type,
that will be called for each item that's either null, or an instance of the specified class;
and a Consumer for the Description type, that will be called each time matcher have to describe
itself. |
FunctionalMatcher(java.lang.Class<? super T> type,
java.util.function.Predicate<T> predicate,
java.lang.String description)
Equal to the
FunctionalMatcher(Class, Predicate, Consumer) but with an automatically created
consumer that calls Description.appendText(String) with the specified string. |
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description) |
java.util.function.Consumer<org.hamcrest.Description> |
getDescriber() |
java.util.function.Predicate<T> |
getPredicate() |
java.lang.Class<? super T> |
getType() |
boolean |
matches(java.lang.Object item) |
public FunctionalMatcher(java.lang.Class<? super T> type, java.util.function.Predicate<T> predicate, java.lang.String description)
FunctionalMatcher(Class, Predicate, Consumer) but with an automatically created
consumer that calls Description.appendText(String) with the specified string.public FunctionalMatcher(java.lang.Class<? super T> type, java.util.function.Predicate<T> predicate, java.util.function.Consumer<org.hamcrest.Description> describer)
Class of items,
for Hamcrest's matchers don't perform any basic type assertion; a Predicate of the same type,
that will be called for each item that's either null, or an instance of the specified class;
and a Consumer for the Description type, that will be called each time matcher have to describe
itself.public java.lang.Class<? super T> getType()
public java.util.function.Predicate<T> getPredicate()
public java.util.function.Consumer<org.hamcrest.Description> getDescriber()
public boolean matches(java.lang.Object item)
public void describeTo(org.hamcrest.Description description)