Class IntNode

java.lang.Object
uk.blankaspect.common.basictree.AbstractNode
uk.blankaspect.common.basictree.IntNode
All Implemented Interfaces:
Cloneable, ITreeNode<AbstractNode>

public class IntNode extends AbstractNode
This class implements a node that contains an integer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NodeType
    The type of an 'int' node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntNode(int value)
    Creates a new instance of an 'int' node that has no parent and has the specified value.
    IntNode(AbstractNode parent, int value)
    Creates a new instance of an 'int' node that has the specified parent and value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates and returns a copy of this 'int' node that has no parent.
    boolean
    Returns true if the specified object is an instance of IntNode and it has the same value as this 'int' node.
    Returns the type of this node.
    int
    Returns the value of this 'int' node.
    int
    Returns the hash code of this 'int' node.
    boolean
    Returns true if this node can contain other nodes.
    static int[]
    nodesToArray(Collection<? extends IntNode> nodes)
    Returns an array whose elements are the values of the specified 'int' nodes, with the order of the elements preserved.
    static List<Integer>
    nodesToList(Iterable<? extends IntNode> nodes)
    Returns a list whose elements are the values of the specified 'int' nodes, with the order of the elements preserved.
    Returns a string representation of this 'int' node.
    static List<IntNode>
    valuesToNodes(int... values)
    Creates a list of 'int' nodes for the specified values, preserving the order of the elements, and returns the list, which may be used to construct a list node.
    static List<IntNode>
    Creates a list of 'int' nodes for the specified values, preserving the order of the elements, and returns the list, which may be used to construct a list node.

    Methods inherited from class uk.blankaspect.common.basictree.AbstractNode

    getChildren, getListIndex, getMapKey, getParent, isRoot, setParent

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

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

    isLeaf
  • Field Details

    • TYPE

      public static final NodeType TYPE
      The type of an 'int' node.
  • Constructor Details

    • IntNode

      public IntNode(int value)
      Creates a new instance of an 'int' node that has no parent and has the specified value.
      Parameters:
      value - the value of the 'int' node.
    • IntNode

      public IntNode(AbstractNode parent, int value)
      Creates a new instance of an 'int' node that has the specified parent and value.
      Parameters:
      parent - the parent of the 'int' node.
      value - the value of the 'int' node.
  • Method Details

    • valuesToNodes

      public static List<IntNode> valuesToNodes(int... values)
      Creates a list of 'int' nodes for the specified values, preserving the order of the elements, and returns the list, which may be used to construct a list node.
      Parameters:
      values - the values for which 'int' nodes will be created.
      Returns:
      a list of 'int' nodes whose underlying values are values.
    • valuesToNodes

      public static List<IntNode> valuesToNodes(Iterable<Integer> values)
      Creates a list of 'int' nodes for the specified values, preserving the order of the elements, and returns the list, which may be used to construct a list node.
      Parameters:
      values - the values for which 'int' nodes will be created.
      Returns:
      a list of 'int' nodes whose underlying values are values.
    • nodesToArray

      public static int[] nodesToArray(Collection<? extends IntNode> nodes)
      Returns an array whose elements are the values of the specified 'int' nodes, with the order of the elements preserved.
      Parameters:
      nodes - the 'int' nodes whose values will be extracted into an array.
      Returns:
      an array whose elements are the values of nodes.
    • nodesToList

      public static List<Integer> nodesToList(Iterable<? extends IntNode> nodes)
      Returns a list whose elements are the values of the specified 'int' nodes, with the order of the elements preserved.
      Parameters:
      nodes - the 'int' nodes whose values will be extracted into a list.
      Returns:
      a list whose elements are the values of nodes.
    • getType

      public NodeType getType()
      Description copied from class: AbstractNode
      Returns the type of this node.
      Specified by:
      getType in class AbstractNode
      Returns:
      TYPE.
    • isContainer

      public boolean isContainer()
      Returns true if this node can contain other nodes. For an 'int' node, this method always returns false.
      Specified by:
      isContainer in class AbstractNode
      Returns:
      false.
    • equals

      public boolean equals(Object obj)
      Returns true if the specified object is an instance of IntNode and it has the same value as this 'int' node.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object with which this 'int' node will be compared.
      Returns:
      true if obj is an instance of IntNode and it has the same value as this 'int' node; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code of this 'int' node.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this 'int' node.
    • clone

      public IntNode clone()
      Creates and returns a copy of this 'int' node that has no parent.
      Overrides:
      clone in class AbstractNode
      Returns:
      a copy of this 'int' node that has no parent.
    • toString

      public String toString()
      Returns a string representation of this 'int' node.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this 'int' node.
    • getValue

      public int getValue()
      Returns the value of this 'int' node.
      Returns:
      the value of this 'int' node.