Interface Node

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractNode, ArrayNode, BuiltinTypeNode, CollectionNode, EnumNode, MapNode, ObjectNode

public interface Node extends Serializable
The interface Node represents the nodes in the tree that models the structure of the program at runtime. See the derived classes to find the appropriate one to instantiate.
  • Method Details

    • getName

      String getName()
      Returns the name of the node
      Returns:
      The name used to display the object represented as a node
    • getType

      Class<?> getType()
      Returns the type of the object represented as a node
      Returns:
      The type of the object represented as a node
    • getValue

      Object getValue()
      Returns the object represented as a node
      Returns:
      The object represented as a node
    • isLeaf

      boolean isLeaf()
      To know if a node is a leaf node.
      Returns:
      Whether the node is a leaf node (no children) or not
    • getChild

      Node getChild(int index)
      Gets the index-th child of the current node.
      Parameters:
      index - The index of the child to be found.
      Returns:
      The index-th child; null if the index is out of bounds.
    • getChildrenCount

      int getChildrenCount()
      Returns the number of children of the current node.
      Returns:
      The number of children of the current node.
    • getIndexOfChild

      int getIndexOfChild(Object child)
      Searches for a child and returns its index. The child node is searched by comparing their names.
      Parameters:
      child - The object to be found (compared by structure with equals)
      Returns:
      The index of the child found; -1 if it no child is found.
    • getNodeDescription

      String getNodeDescription()
      A textual description of the node. toString must be defined for the wrapped objects.
      Returns:
      The string representation of the node.
    • getClassName

      String getClassName()
      Returns the short name of the type whose object is wrapped by the node.
      Returns:
      A short name of the type of the object wrapped by the node.
    • compareTrees

      Set<Node> compareTrees(Node node2, boolean equalName, Set<Node> modifiedNodes, Set<SymmetricPair<Node,Node>> alreadyTraversed)
      Compare two trees and return the list of modified nodes.
      Parameters:
      node2 - The node to compare with the other tree
      equalName - Whether the node names must be the same or not (important for root nodes)
      modifiedNodes - The list of modified nodes
      alreadyTraversed - The list of nodes that have been visited in this traversal
      Returns:
      The list of modified nodes