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