public interface ComparisonPerformer<T> extends java.util.function.BiFunction<T,T,ComparisonResult>, java.util.function.BiPredicate<T,T>
Comparison performer represents both a BiFunction that converts two instances of the same type
into a ComparisonResult, and a BiPredicate that converts two instances of the same type
into a boolean answer.
Main function of a performer is to perform some complex comparison and to provide a proper extended result. But sometimes there's no need for a result like this, and a simple "yes/no" answer will suffice. For case like this it is also a predicate.
Note: there's a default implementation of the test(Object, Object) method that simply
calls apply(Object, Object) and then checks received result for success. But more complex performers
might also override it and provide it's own implementation, for example to limit some costly operations, required
for a more extended compare.
| Modifier and Type | Method and Description |
|---|---|
ComparisonResult |
apply(T actual,
T expected) |
default java.lang.String |
getName()
Used to identify performer in a result.
|
default boolean |
test(T a,
T b)
May be used in case simple yes/no answer is enough and there's no need for extended
ComparisonResult. |
ComparisonResult apply(T actual, T expected)
apply in interface java.util.function.BiFunction<T,T,ComparisonResult>default boolean test(T a, T b)
ComparisonResult.
Note: by default this method just calls apply(Object, Object) and checks result for success.test in interface java.util.function.BiPredicate<T,T>apply(Object, Object)default java.lang.String getName()