Package introspector.model
Class AbstractNode
java.lang.Object
introspector.model.AbstractNode
- All Implemented Interfaces:
Node,Serializable
- Direct Known Subclasses:
ArrayNode,BuiltinTypeNode,CollectionNode,EnumNode,MapNode,ObjectNode
The abstract Node provides the default implementation of the Node interface.
The node interface 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.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNode(String name, Object value) Creates a Node that wraps a Java ObjectprotectedAbstractNode(String name, Object value, Class<?> type) Creates a Node that wraps a Java Object -
Method Summary
Modifier and TypeMethodDescriptioncompareTrees(Node node2, boolean equalName, Set<Node> modifiedNodes, Set<SymmetricPair<Node, Node>> alreadyTraversed) Compare two trees and return the list of modified nodes.booleanTwo nodes are equal when they wrap the same exact object (identity comparison)getChild(int index) Gets the index-th child of the current node.Returns the child node of the current node.intReturns the number of children of the current node.Returns the short name of the type whose object is wrapped by the node.intgetIndexOfChild(Object child) Searches for a child and returns its index.getName()Returns the name of the nodeA textual description of the node.Class<?> getType()Returns the type of the object represented as a nodegetValue()Returns the object represented as a nodeinthashCode()toString()A node is represented as "name (type)".
-
Field Details
-
value
The object that is wrapped by the node -
name
The name of the node -
type
The type of the node
-
-
Constructor Details
-
AbstractNode
Creates a Node that wraps a Java Object- Parameters:
name- The name to display the nodevalue- The object that will be represented as a node
-
AbstractNode
Creates a Node that wraps a Java Object- Parameters:
name- The name to display the nodevalue- The object that will be represented as a nodetype- The type of the object
-
-
Method Details
-
getName
Description copied from interface:NodeReturns the name of the node -
getType
Description copied from interface:NodeReturns the type of the object represented as a node -
getValue
Description copied from interface:NodeReturns the object represented as a node -
getChildren
Returns the child node of the current node. Template method to implementNode.getChild(int),Node.getChildrenCount()andNode.getIndexOfChild(Object)- Returns:
- The children of this node (null if there are no children)
-
getChild
Description copied from interface:NodeGets the index-th child of the current node. -
getChildrenCount
public int getChildrenCount()Description copied from interface:NodeReturns the number of children of the current node.- Specified by:
getChildrenCountin interfaceNode- Returns:
- The number of children of the current node.
- See Also:
-
getIndexOfChild
Description copied from interface:NodeSearches for a child and returns its index. The child node is searched by comparing their names.- Specified by:
getIndexOfChildin interfaceNode- 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.
- See Also:
-
toString
A node is represented as "name (type)". -
equals
Two nodes are equal when they wrap the same exact object (identity comparison) -
hashCode
public int hashCode() -
getNodeDescription
Description copied from interface:NodeA textual description of the node. toString must be defined for the wrapped objects.- Specified by:
getNodeDescriptionin interfaceNode- Returns:
- The string representation of the node.
- See Also:
-
getClassName
Description copied from interface:NodeReturns the short name of the type whose object is wrapped by the node.- Specified by:
getClassNamein interfaceNode- Returns:
- A short name of the type of the object wrapped by the node.
- See Also:
-
compareTrees
public Set<Node> compareTrees(Node node2, boolean equalName, Set<Node> modifiedNodes, Set<SymmetricPair<Node, Node>> alreadyTraversed) Description copied from interface:NodeCompare two trees and return the list of modified nodes.- Specified by:
compareTreesin interfaceNode- Parameters:
node2- The node to compare with the other treeequalName- Whether the node names must be the same or not (important for root nodes)modifiedNodes- The list of modified nodesalreadyTraversed- The list of nodes that have been visited in this traversal- Returns:
- The list of modified nodes
- See Also:
-