Class TreeComparator

java.lang.Object
introspector.model.traverse.TreeComparator

public class TreeComparator extends Object
Class that compares two trees and writes the differences in lists of files
  • Constructor Details

    • TreeComparator

      public TreeComparator()
  • Method Details

    • compareTrees

      public Set<Node> compareTrees(TreePath path1, TreePath path2)
      Compares two trees and returns true if they are equal, false otherwise
      Parameters:
      path1 - the root of the first tree
      path2 - 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

      public Set<Node> compareTrees(Object tree1, Object tree2)
      Compares two trees and returns true if they are equal, false otherwise
      Parameters:
      tree1 - the root of the first tree
      tree2 - 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 tree
      object2 - the root of the second tree
      equalName - whether the names of the nodes should be compared
      modifiedNodes - the list of modified nodes
      alreadyTraversed - the list of nodes that have been visited in this traversal
      Returns:
      the set of different nodes
    • createNodeIfNeeded

      private static Node createNodeIfNeeded(Object object)
      Makes sure the object is a node by creating a node wrapping the object if needed