public final class TreeComparison<E,A> extends Object
A mechanism for comparing trees.
Modifier and Type | Class and Description |
---|---|
static class |
TreeComparison.SameType<T>
An API for comparing trees which have been mapped to the same type.
|
Modifier and Type | Method and Description |
---|---|
void |
assertEqual()
Asserts that the trees are equal, based on
Objects.equals() . |
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 |
isEqual()
Returns true if the two trees are equal, based on
Objects.equals . |
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)
Returns true if the two trees are equal, by calling Objects.equals(Object, Object)
on the results of both mappers.
public boolean isEqualBasedOn(BiPredicate<? super E,? super A> compareFunc)
Returns true if the two trees are equal, based on the given BiPredicate
.
public boolean isEqual()
Returns true if the two trees are equal, based on Objects.equals
.
public 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.
isEqualMappedBy(Function, Function)
public void assertEqualBasedOn(BiPredicate<E,A> compareFunc)
Asserts that the trees are equal, based on the given BiPredicate
.
isEqualBasedOn(BiPredicate)
public void assertEqual()
Asserts that the trees are equal, based on Objects.equals()
.
isEqualBasedOn(BiPredicate)
public TreeComparison<E,A> decorateErrorsWith(Function<? super E,String> expectedToString, Function<? super A,String> actualToString)
Decorates errors thrown by any assertions with the given functions.
public <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.
public 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.
public 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.
public 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.
public 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.
public 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.