Package com.mackenziehigh.sexpr
Class SList.Mutator
java.lang.Object
com.mackenziehigh.sexpr.SList.Mutator
- Enclosing class:
- SList
An instance of this interface simplifies the modification
of symbolic-expressions, since they are immutable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method appends the given value onto the selected node, if the selected node is a symbolic-list.first()
This method selects the first element in the currently selected list node().get
(int index) This method selects an element in the currently selected list node().last()
This method selects the last element in the currently selected list node().Sexpr<?>
node()
This method retrieves the currently selected node.This method prepends the given value onto the selected node, if the selected node is a symbolic-list.This method sets the selected node to the given value.toString()
-
Constructor Details
-
Mutator
Sole Public Constructor.- Parameters:
node
- is the root of a symbolic-expression tree.
-
-
Method Details
-
append
This method appends the given value onto the selected node, if the selected node is a symbolic-list.- Parameters:
value
- is the value to append onto the node().- Returns:
- a modified copy of the symbolic-expression.
- Throws:
IllegalStateException
- if node().isList() is false.
-
prepend
This method prepends the given value onto the selected node, if the selected node is a symbolic-list.- Parameters:
value
- is the value to prepend onto the node().- Returns:
- a modified copy of the symbolic-expression.
- Throws:
IllegalStateException
- if node().isList() is false.
-
set
This method sets the selected node to the given value.- Parameters:
value
- will replace the node() in the tree.- Returns:
- a modified copy of the symbolic-expression.
- Throws:
IllegalStateException
- if the selected node is the root of the tree.
-
first
This method selects the first element in the currently selected list node().- Returns:
- a new instance of this class, which encodes this action.
- Throws:
IllegalStateException
- if node().isList() is false.IndexOutOfBoundsException
- if node() is the list is empty.
-
last
This method selects the last element in the currently selected list node().- Returns:
- a new instance of this class, which encodes this action.
- Throws:
IllegalStateException
- if node().isList() is false.IndexOutOfBoundsException
- if node() is the list is empty.
-
get
This method selects an element in the currently selected list node().- Parameters:
index
- is the index of the element to select.- Returns:
- a new instance that encodes this action.
- Throws:
IllegalStateException
- if node().isList() is false.IndexOutOfBoundsException
- if node() is the list is empty.
-
node
This method retrieves the currently selected node.- Returns:
- the selected node.
-
toString
-