Package introspector.model.traverse
Class TreeComparator
java.lang.Object
introspector.model.traverse.TreeComparator
Class that compares two trees and writes the differences in lists of files
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompareNode(Object object1, Object object2, boolean equalName, Set<Node> modifiedNodes, Set<SymmetricPair<Node, Node>> alreadyTraversed) Compares two trees and returns the list of different nodescompareTrees(Object tree1, Object tree2) Compares two trees and returns true if they are equal, false otherwisecompareTrees(TreePath path1, TreePath path2) Compares two trees and returns true if they are equal, false otherwiseprivate static NodecreateNodeIfNeeded(Object object) Makes sure the object is a node by creating a node wrapping the object if needed
-
Constructor Details
-
TreeComparator
public TreeComparator()
-
-
Method Details
-
compareTrees
Compares two trees and returns true if they are equal, false otherwise- Parameters:
path1- the root of the first treepath2- the root of the second tree- Returns:
- true if the trees are equal, false otherwise. The three lists are updated with the differences: newNodes, deletedNodes and modifiedNodes.
-
compareTrees
Compares two trees and returns true if they are equal, false otherwise- Parameters:
tree1- the root of the first treetree2- the root of the second tree- Returns:
- the set of different nodes (if any)
-
compareNode
private Set<Node> compareNode(Object object1, Object object2, boolean equalName, Set<Node> modifiedNodes, Set<SymmetricPair<Node, Node>> alreadyTraversed) Compares two trees and returns the list of different nodes- Parameters:
object1- the root of the first treeobject2- the root of the second treeequalName- whether the names of the nodes should be comparedmodifiedNodes- the list of modified nodesalreadyTraversed- the list of nodes that have been visited in this traversal- Returns:
- the set of different nodes
-
createNodeIfNeeded
Makes sure the object is a node by creating a node wrapping the object if needed
-