public abstract class BaseCompositeMatcher<T> extends BaseMatcher<T>
T
, create a subclass that
uses expectThat()
to add
Matchers that compare instances property-by-property.Modifier | Constructor and Description |
---|---|
protected |
BaseCompositeMatcher(T expected)
Creates a new BaseCompositeMatcher instance.
|
Modifier and Type | Method and Description |
---|---|
protected static <T> ContainsElements.Supplier<T> |
containsElementsMatching(Function<T,Matcher<T>> elementMatcherSupplier)
Returns a new
ContainsElements.Supplier that supplies a ContainsElements matcher using
the given element Matcher supplier. |
protected static <K,V> ContainsEntries.Supplier<K,V> |
containsEntriesMatching(Function<K,Matcher<K>> keyMatcherSupplier,
Function<V,Matcher<V>> valueMatcherSupplier)
Returns a new
ContainsEntries.Supplier that supplies a ContainsEntries matcher that
matches entries using the given key and value Matcher suppliers. |
protected static <K,V> ContainsEntries.Supplier<K,V> |
containsEntriesMatching(Function<V,Matcher<V>> valueMatcherSupplier)
Returns a new
ContainsEntries.Supplier that supplies a ContainsEntries matcher that
matches entries using the given value Matcher supplier. |
protected static <T,S extends Iterable<T>> |
containsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
Returns a new
ContainsMembers.Supplier that supplies a ContainsMembers matcher using
the given member Matcher supplier. |
void |
describeMismatch(Object actual,
Description description) |
void |
describeTo(Description description) |
protected void |
expectThat(Function<T,Matcher<? super T>> matcherSupplier)
Adds the Matcher supplied for the expected object to the matchers applied by this Matcher.
|
protected <R> void |
expectThat(String functionName,
Function<T,R> function,
Function<R,Matcher<R>> resultMatcherSupplier)
Adds a
MatchesFunction matcher for the expected object to the matchers applied by this Matcher. |
protected Matcher<? super T> |
getTypeMismatch(Object object)
If the given object is incompatible with the expected type, returns a Matcher that describes the mismatch.
|
protected static <T> ListsElements.Supplier<T> |
listsElementsMatching(Function<T,Matcher<T>> elementMatcherSupplier)
Returns a new
ListsElements.Supplier that supplies a ListsElements matcher using
the given element Matcher supplier. |
protected static <T,S extends Iterable<T>> |
listsMatching(Function<T,Matcher<T>> memberMatcherSupplier)
Returns a new
ListsMatching.Supplier that supplies a ListsMatching matcher using
the given member Matcher supplier. |
protected static <T,S extends Iterable<T>> |
listsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
Returns a new
ListsMembers.Supplier that supplies a ListsMembers matcher using
the given member Matcher supplier. |
protected Function<T,Matcher<? super T>> |
matches(Function<T,Matcher<? super T>> matcherSupplier)
Decorates another Matcher supplier to provide a more expressive interface.
|
boolean |
matches(Object actual) |
String |
toString() |
protected <R> MatchesFunction.Supplier<T,R> |
valueOf(String functionName,
Function<T,R> function)
Returns a new
MatchesFunction.Supplier that supplies a MatchesFunction matcher using
the given function. |
protected static <T> VisitsList.Supplier<T> |
visitsListMatching(Function<T,Matcher<T>> memberMatcherSupplier)
Returns a new
VisitsList.Supplier that supplies a VisitsList matcher using
the given member Matcher supplier. |
protected static <T> VisitsMembers.Supplier<T> |
visitsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
Returns a new
VisitsMembers.Supplier that supplies a VisitsMembers matcher using
the given member Matcher supplier. |
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull
protected BaseCompositeMatcher(T expected)
public boolean matches(Object actual)
public void describeTo(Description description)
public void describeMismatch(Object actual, Description description)
describeMismatch
in interface Matcher<T>
describeMismatch
in class BaseMatcher<T>
protected Matcher<? super T> getTypeMismatch(Object object)
protected void expectThat(Function<T,Matcher<? super T>> matcherSupplier)
protected <R> void expectThat(String functionName, Function<T,R> function, Function<R,Matcher<R>> resultMatcherSupplier)
MatchesFunction
matcher for the expected object to the matchers applied by this Matcher.protected Function<T,Matcher<? super T>> matches(Function<T,Matcher<? super T>> matcherSupplier)
protected <R> MatchesFunction.Supplier<T,R> valueOf(String functionName, Function<T,R> function)
MatchesFunction.Supplier
that supplies a MatchesFunction
matcher using
the given function.protected static <T,S extends Iterable<T>> ContainsMembers.Supplier<T,S> containsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
ContainsMembers.Supplier
that supplies a ContainsMembers
matcher using
the given member Matcher supplier.protected static <T> ContainsElements.Supplier<T> containsElementsMatching(Function<T,Matcher<T>> elementMatcherSupplier)
ContainsElements.Supplier
that supplies a ContainsElements
matcher using
the given element Matcher supplier.protected static <T> VisitsMembers.Supplier<T> visitsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
VisitsMembers.Supplier
that supplies a VisitsMembers
matcher using
the given member Matcher supplier.protected static <T,S extends Iterable<T>> ListsMembers.Supplier<T,S> listsMembersMatching(Function<T,Matcher<T>> memberMatcherSupplier)
ListsMembers.Supplier
that supplies a ListsMembers
matcher using
the given member Matcher supplier.protected static <T,S extends Iterable<T>> ListsMatching.Supplier<T,S> listsMatching(Function<T,Matcher<T>> memberMatcherSupplier)
ListsMatching.Supplier
that supplies a ListsMatching
matcher using
the given member Matcher supplier.protected static <T> ListsElements.Supplier<T> listsElementsMatching(Function<T,Matcher<T>> elementMatcherSupplier)
ListsElements.Supplier
that supplies a ListsElements
matcher using
the given element Matcher supplier.protected static <T> VisitsList.Supplier<T> visitsListMatching(Function<T,Matcher<T>> memberMatcherSupplier)
VisitsList.Supplier
that supplies a VisitsList
matcher using
the given member Matcher supplier.protected static <K,V> ContainsEntries.Supplier<K,V> containsEntriesMatching(Function<V,Matcher<V>> valueMatcherSupplier)
ContainsEntries.Supplier
that supplies a ContainsEntries
matcher that
matches entries using the given value Matcher supplier.protected static <K,V> ContainsEntries.Supplier<K,V> containsEntriesMatching(Function<K,Matcher<K>> keyMatcherSupplier, Function<V,Matcher<V>> valueMatcherSupplier)
ContainsEntries.Supplier
that supplies a ContainsEntries
matcher that
matches entries using the given key and value Matcher suppliers.public String toString()
toString
in class BaseMatcher<T>
Copyright © 2022 The Cornutum Project. All rights reserved.