Package uk.blankaspect.common.basictree
Class DoubleNode
java.lang.Object
uk.blankaspect.common.basictree.AbstractNode
uk.blankaspect.common.basictree.DoubleNode
- All Implemented Interfaces:
Cloneable
,ITreeNode<AbstractNode>
This class implements a node that contains a double-precision floating-point number.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDoubleNode
(double value) Creates a new instance of a 'double' node that has no parent and has the specified value.DoubleNode
(AbstractNode parent, double value) Creates a new instance of a 'double' node that has the specified parent and value. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates and returns a copy of this 'double' node that has no parent.boolean
Returnstrue
if the specified object is an instance ofDoubleNode
and it has the same value as this 'double' node.getType()
Returns the type of this node.double
getValue()
Returns the value of this 'double' node.int
hashCode()
Returns the hash code of this 'double' node.boolean
Returnstrue
if this node can contain other nodes.static double[]
nodesToArray
(Collection<? extends DoubleNode> nodes) Returns an array whose elements are the values of the specified 'double' nodes, with the order of the elements preserved.nodesToList
(Iterable<? extends DoubleNode> nodes) Returns a list whose elements are the values of the specified 'double' nodes, with the order of the elements preserved.toString()
Returns a string representation of this 'double' node.static List<DoubleNode>
valuesToNodes
(double... values) Creates a list of 'double' 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<DoubleNode>
valuesToNodes
(Iterable<Double> values) Creates a list of 'double' 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
-
Field Details
-
TYPE
The type of a 'double' node.
-
-
Constructor Details
-
DoubleNode
public DoubleNode(double value) Creates a new instance of a 'double' node that has no parent and has the specified value.- Parameters:
value
- the value of the 'double' node.
-
DoubleNode
Creates a new instance of a 'double' node that has the specified parent and value.- Parameters:
parent
- the parent of the 'double' node.value
- the value of the 'double' node.
-
-
Method Details
-
valuesToNodes
Creates a list of 'double' 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 'double' nodes will be created.- Returns:
- a list of 'double' nodes whose underlying values are
values
.
-
valuesToNodes
Creates a list of 'double' 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 'double' nodes will be created.- Returns:
- a list of 'double' nodes whose underlying values are
values
.
-
nodesToArray
Returns an array whose elements are the values of the specified 'double' nodes, with the order of the elements preserved.- Parameters:
nodes
- the 'double' nodes whose values will be extracted into an array.- Returns:
- an array whose elements are the values of
nodes
.
-
nodesToList
Returns a list whose elements are the values of the specified 'double' nodes, with the order of the elements preserved.- Parameters:
nodes
- the 'double' nodes whose values will be extracted into a list.- Returns:
- a list whose elements are the values of
nodes
.
-
getType
Description copied from class:AbstractNode
Returns the type of this node.- Specified by:
getType
in classAbstractNode
- Returns:
TYPE
.
-
isContainer
public boolean isContainer()Returnstrue
if this node can contain other nodes. For a 'double' node, this method always returnsfalse
.- Specified by:
isContainer
in classAbstractNode
- Returns:
false
.
-
equals
Returnstrue
if the specified object is an instance ofDoubleNode
and it has the same value as this 'double' node. -
hashCode
public int hashCode()Returns the hash code of this 'double' node. -
clone
Creates and returns a copy of this 'double' node that has no parent.- Overrides:
clone
in classAbstractNode
- Returns:
- a copy of this 'double' node that has no parent.
-
toString
Returns a string representation of this 'double' node. -
getValue
public double getValue()Returns the value of this 'double' node.- Returns:
- the value of this 'double' node.
-