public final class TreeComparison<E,A> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
TreeComparison.SameType<T>
An API for comparing trees which have been mapped to the same type.
|
Modifier and Type | Method and Description |
---|---|
void |
assertEqualBasedOn(BiPredicate<E,A> compareFunc)
Asserts that the trees are equal, based on the given
BiPredicate . |
void |
assertEqualMappedBy(Function<? super E,?> expectedMapper,
Function<? super A,?> actualMapper)
Asserts that the trees are equal, by calling
Objects.equals(Object, Object) on the results of both mappers. |
TreeComparison<E,A> |
decorateErrorsWith(Function<? super E,String> expectedToString,
Function<? super A,String> actualToString)
Decorates errors thrown by any assertions with the given functions.
|
boolean |
isEqualBasedOn(BiPredicate<? super E,? super A> compareFunc)
Returns true if the two trees are equal, based on the given
BiPredicate . |
boolean |
isEqualMappedBy(Function<? super E,?> expectedMapper,
Function<? super A,?> actualMapper)
Returns true if the two trees are equal, by calling
Objects.equals(Object, Object) on the results of both mappers. |
<T> TreeComparison.SameType<T> |
mapToSame(Function<? super E,? extends T> mapExpected,
Function<? super A,? extends T> mapActual)
Maps both sides of the comparison to the same type, for easier comparison and assertions.
|
static <E,A> TreeComparison<E,A> |
of(TreeDef<E> expectedDef,
E expectedRoot,
TreeDef<A> actualDef,
A actualRoot)
Creates a
TreeComparison for comparing the two trees. |
static <T> TreeComparison.SameType<T> |
of(TreeDef<T> treeDef,
T expected,
T actual)
Creates a
TreeComparison.SameType for comparing two trees of the same type. |
static <T> TreeComparison.SameType<T> |
of(TreeNode<T> expected,
TreeDef<T> treeDef,
T actual)
Creates a
TreeComparison.SameType for comparing a TreeNode against a generic tree. |
static <T,U> TreeComparison.SameType<T> |
of(TreeNode<T> expected,
TreeDef<U> treeDef,
U actual,
Function<? super U,? extends T> mapper)
Creates a
TreeComparison.SameType for comparing a TreeNode against a generic tree which been mapped. |
static <T> TreeComparison.SameType<T> |
of(TreeNode<T> expected,
TreeNode<T> actual)
Creates a
TreeComparison.SameType from the given two TreeNode s of the same type. |
public boolean isEqualMappedBy(Function<? super E,?> expectedMapper, Function<? super A,?> actualMapper)
Objects.equals(Object, Object)
on the results of both mappers.public boolean isEqualBasedOn(BiPredicate<? super E,? super A> compareFunc)
BiPredicate
.public void assertEqualMappedBy(Function<? super E,?> expectedMapper, Function<? super A,?> actualMapper)
Objects.equals(Object, Object)
on the results of both mappers.isEqualMappedBy(Function, Function)
public void assertEqualBasedOn(BiPredicate<E,A> compareFunc)
BiPredicate
.isEqualBasedOn(BiPredicate)
public TreeComparison<E,A> decorateErrorsWith(Function<? super E,String> expectedToString, Function<? super A,String> actualToString)
public <T> TreeComparison.SameType<T> mapToSame(Function<? super E,? extends T> mapExpected, Function<? super A,? extends T> mapActual)
public static <E,A> TreeComparison<E,A> of(TreeDef<E> expectedDef, E expectedRoot, TreeDef<A> actualDef, A actualRoot)
TreeComparison
for comparing the two trees.public static <T> TreeComparison.SameType<T> of(TreeDef<T> treeDef, T expected, T actual)
TreeComparison.SameType
for comparing two trees of the same type.public static <T> TreeComparison.SameType<T> of(TreeNode<T> expected, TreeDef<T> treeDef, T actual)
TreeComparison.SameType
for comparing a TreeNode
against a generic tree.public static <T,U> TreeComparison.SameType<T> of(TreeNode<T> expected, TreeDef<U> treeDef, U actual, Function<? super U,? extends T> mapper)
TreeComparison.SameType
for comparing a TreeNode
against a generic tree which been mapped.public static <T> TreeComparison.SameType<T> of(TreeNode<T> expected, TreeNode<T> actual)
TreeComparison.SameType
from the given two TreeNode
s of the same type.