T - the type of the entities to be matched.public abstract class IsEqualToEntity<T>
extends org.hamcrest.TypeSafeMatcher<T>
Matcher that can be used to create new matchers that
compare entities by their attributes.| Modifier and Type | Field and Description |
|---|---|
protected T |
expected
The expected entity.
|
| Constructor and Description |
|---|
IsEqualToEntity(T entity)
Constructs a new instance of
IsEqualToEntity. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMatcherDescription(org.hamcrest.Matcher<?> matcher)
Adds as the description of this matcher the
SelfDescribing.describeTo(Description) method of other matcher. |
protected void |
addTemplatedDescription(String attribute,
Object expected)
Adds a new description using the template:
|
protected <R> boolean |
checkArrayAttribute(String attribute,
Function<T,R[]> getter,
T actual)
Compares the expected and the actual value of an array attribute.
|
protected <R> boolean |
checkArrayAttribute(String attribute,
Function<T,R[]> getter,
T actual,
Function<R[],org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
Compares the expected and the actual value of an array attribute.
|
protected <R> boolean |
checkAttribute(String attribute,
Function<T,R> getter,
T actual)
Compares the expected and the actual value of an attribute.
|
protected <R> boolean |
checkAttribute(String attribute,
Function<T,R> getter,
T actual,
Function<R,org.hamcrest.Matcher<R>> matcherFactory) |
protected boolean |
checkIntArrayAttribute(String attribute,
Function<T,int[]> getter,
T actual)
Compares the expected and the actual value of an int array attribute.
|
protected <R> boolean |
checkIterableAttribute(String attribute,
Function<T,Iterable<R>> getter,
T actual,
Function<Iterable<R>,org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
Compares the expected and the actual value of an iterable attribute.
|
protected void |
clearDescribeTo()
Cleans the current description.
|
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
Iterable<T> entities)
Generates a Hamcrest matcher that compares an
Iterable of entities in **any order**. |
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
T... entities)
Generates a Hamcrest matcher that compares an array of entities in **any order**.
|
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
Iterable<T> entities)
Generates a Hamcrest matcher that compares an
Iterable of entities in **the given order**. |
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
T... entities)
Generates a Hamcrest matcher that compares an array of entities in **the given order**.
|
void |
describeTo(org.hamcrest.Description description) |
describeMismatch, describeMismatchSafely, matches, matchesSafelyprotected final T expected
public IsEqualToEntity(T entity)
IsEqualToEntity.entity - the expected entity.public void describeTo(org.hamcrest.Description description)
protected void addTemplatedDescription(String attribute, Object expected)
<expected class> entity with value '<expected>' for <attribute>
attribute - the name of the attribute compared.expected - the expected value.protected void addMatcherDescription(org.hamcrest.Matcher<?> matcher)
SelfDescribing.describeTo(Description) method of other matcher.matcher - the matcher whose description will be used.protected void clearDescribeTo()
protected <R> boolean checkAttribute(String attribute, Function<T,R> getter, T actual, Function<R,org.hamcrest.Matcher<R>> matcherFactory)
protected <R> boolean checkArrayAttribute(String attribute, Function<T,R[]> getter, T actual, Function<R[],org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
R - type of the value returned by the getter.attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected
entity.matcherFactory - a function that creates a matcher for the expected
array values.true if the value of the expected and actual attributes are
equals and false otherwise. If the result is false,
the current description will be updated.protected <R> boolean checkIterableAttribute(String attribute, Function<T,Iterable<R>> getter, T actual, Function<Iterable<R>,org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
R - type of the value returned by the getter.attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected
entity.matcherFactory - a function that creates a matcher for the expected
iterable values.true if the value of the expected and actual attributes are
equals and false otherwise. If the result is false,
the current description will be updated.protected <R> boolean checkAttribute(String attribute, Function<T,R> getter, T actual)
R - type of the value returned by the getter.attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected entity.true if the value of the expected and actual attributes are
equals and false otherwise. If the result is false,
the current description will be updated.protected <R> boolean checkArrayAttribute(String attribute, Function<T,R[]> getter, T actual)
R - type of the value returned by the getter.attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected entity.true if the value of the expected and actual attributes are
equals and false otherwise. If the result is false,
the current description will be updated.protected boolean checkIntArrayAttribute(String attribute, Function<T,int[]> getter, T actual)
attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected entity.true if the value of the expected and actual attributes are
equals and false otherwise. If the result is false,
the current description will be updated.protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, Iterable<T> entities)
Iterable of entities in **any order**.
Each entity in the entities collection is converted to a matcher using the provided converter function.
The resulting matcher will succeed if the actual Iterable contains all expected entities, regardless of order.
T - the type of the entities being comparedconverter - a function that converts each entity to a Matcher for comparisonentities - the expected entities to matchMatcher that verifies the actual Iterable contains the expected entities in any order@SafeVarargs protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, T... entities)
Each entity in the entities array is converted to a matcher using the provided converter function.
The resulting matcher will succeed if the actual Iterable contains all expected entities, regardless of order.
T - the type of the entities being comparedconverter - a function that converts each entity to a Matcher for comparisonentities - the expected entities to match (varargs)Matcher that verifies the actual Iterable contains the expected entities in any orderprotected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, Iterable<T> entities)
Iterable of entities in **the given order**.
Each entity in the entities collection is converted to a matcher using the provided converter function.
The resulting matcher will succeed only if the actual Iterable contains the expected entities in the same order.
T - the type of the entities being comparedconverter - a function that converts each entity to a Matcher for comparisonentities - the expected entities to matchMatcher that verifies the actual Iterable contains the expected entities in order@SafeVarargs protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, T... entities)
Each entity in the entities array is converted to a matcher using the provided converter function.
The resulting matcher will succeed only if the actual Iterable contains the expected entities in the same order.
T - the type of the entities being comparedconverter - a function that converts each entity to a Matcher for comparisonentities - the expected entities to match (varargs)Matcher that verifies the actual Iterable contains the expected entities in orderCopyright © 2025. All rights reserved.