Class NodeType

java.lang.Object
uk.blankaspect.common.basictree.NodeType
All Implemented Interfaces:
ITreeNode<NodeType>

public final class NodeType extends Object implements ITreeNode<NodeType>
This class represents the type of a node. Node types form a hierarchy whose root is ANY, the node type of AbstractNode. The hierarchy of node types mirrors the hierarchy of the classes with which the node types are associated, so node types are likely to be useful only when it is inconvenient to work with the classes of nodes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NodeType
    The root of the node-type hierarchy.
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeType(NodeType parent, Class<? extends AbstractNode> nodeClass)
    Creates a new node type that has the specified parent and is associated with the specified class of node.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an unmodifiable list of the child types of this node type.
    Class<? extends AbstractNode>
    Returns the class of node with which this node type is associated.
    Returns the parent type of this node type.
    boolean
    is(NodeType nodeType)
    Returns true if this node type is identical to or a subtype (ie, descendant) of the specified node type.
    boolean
    Returns true if this node type is identical to or a subtype (ie, descendant) of any of the specified node types.
    boolean
    isAnyOf(NodeType... nodeTypes)
    Returns true if this node type is identical to or a subtype (ie, descendant) of any of the specified node types.
    Returns a string representation of this node type, which is the name of the class of node with which this node type is associated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface uk.blankaspect.common.tree.ITreeNode

    isLeaf
  • Field Details

    • ANY

      public static final NodeType ANY
      The root of the node-type hierarchy.
  • Constructor Details

    • NodeType

      public NodeType(NodeType parent, Class<? extends AbstractNode> nodeClass)
      Creates a new node type that has the specified parent and is associated with the specified class of node.
      Parameters:
      parent - the parent of the node type.
      nodeClass - the class of node with which the node type will be associated.
      Throws:
      IllegalArgumentException - if
      • parent is null or
      • nodeClass is null or
      • the node class of parent is not a superclass of nodeClass or
      • parent already has a child that is associated with nodeClass.
  • Method Details

    • getParent

      public NodeType getParent()
      Returns the parent type of this node type.
      Specified by:
      getParent in interface ITreeNode<NodeType>
      Returns:
      the parent type of this node type.
    • getChildren

      public List<NodeType> getChildren()
      Returns an unmodifiable list of the child types of this node type.
      Specified by:
      getChildren in interface ITreeNode<NodeType>
      Returns:
      an unmodifiable list of the child types of this node type.
    • toString

      public String toString()
      Returns a string representation of this node type, which is the name of the class of node with which this node type is associated.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this node type.
    • getNodeClass

      public Class<? extends AbstractNode> getNodeClass()
      Returns the class of node with which this node type is associated.
      Returns:
      the class of node with which this node type is associated.
    • is

      public boolean is(NodeType nodeType)
      Returns true if this node type is identical to or a subtype (ie, descendant) of the specified node type.
      Parameters:
      nodeType - the node type with which this node type will be compared.
      Returns:
      true if this node type is identical to or a subtype of nodeType; false otherwise.
    • isAnyOf

      public boolean isAnyOf(NodeType... nodeTypes)
      Returns true if this node type is identical to or a subtype (ie, descendant) of any of the specified node types.
      Parameters:
      nodeTypes - the node types with which this node type will be compared.
      Returns:
      true if this node type is identical to or a subtype of any of nodeTypes; false otherwise.
    • isAnyOf

      public boolean isAnyOf(Iterable<NodeType> nodeTypes)
      Returns true if this node type is identical to or a subtype (ie, descendant) of any of the specified node types.
      Parameters:
      nodeTypes - the node types with which this node type will be compared.
      Returns:
      true if this node type is identical to or a subtype of any of nodeTypes; false otherwise.