public final class Block extends java.lang.Object implements MethodBody, StatementWithoutTrailingSubstatement
Block
denotes the nonterminal symbol Block, as defined by the Java Language Specification.
This class is mutable and therefore not suitable for concurrent use without external synchronization.
Modifier and Type | Method and Description |
---|---|
boolean |
accept(org.macroing.cit.java.util.node.NodeHierarchicalVisitor nodeHierarchicalVisitor)
Accepts a
NodeHierarchicalVisitor . |
void |
addBlockStatement(BlockStatement blockStatement)
|
void |
addComment(Comment comment)
Adds a
Comment to the end of this Block instance. |
void |
addWhiteSpace(WhiteSpace whiteSpace)
Adds a
WhiteSpace to the end of this Block instance. |
boolean |
equals(java.lang.Object object)
Returns
true if, and only if, object is an instance of Block , and that Block instance is equal to this Block instance, false otherwise. |
java.util.List<BlockStatement> |
getBlockStatements()
Returns a
List with all currently added BlockStatement s. |
int |
hashCode()
Returns a hash code for this
Block instance. |
boolean |
isIterationStatement()
Returns
true if, and only if, this Statement is an iteration statement, false otherwise. |
static Block |
newInstance()
Returns a new empty
Block instance. |
void |
removeBlockStatement(BlockStatement blockStatement)
Removes the first
BlockStatement from the end of the BlockStatement s section of this Block instance, that is equal to blockStatement . |
void |
removeComment(Comment comment)
|
void |
removeWhiteSpace(WhiteSpace whiteSpace)
|
java.lang.String |
toString()
Returns a
String representation of this Block instance. |
public boolean accept(org.macroing.cit.java.util.node.NodeHierarchicalVisitor nodeHierarchicalVisitor)
NodeHierarchicalVisitor
.
Returns the result of nodeHierarchicalVisitor.visitLeave(this)
.
If nodeHierarchicalVisitor
is null
, a NullPointerException
will be thrown.
If a RuntimeException
is thrown by the current NodeHierarchicalVisitor
, a NodeTraversalException
will be thrown with the RuntimeException
wrapped.
This implementation will:
NullPointerException
if nodeHierarchicalVisitor
is null
.NodeTraversalException
if nodeHierarchicalVisitor
throws a RuntimeException
.Node
s, if it has any.accept
in interface org.macroing.cit.java.util.node.Node
nodeHierarchicalVisitor
- the NodeHierarchicalVisitor
to acceptnodeHierarchicalVisitor.visitLeave(this)
org.macroing.cit.java.util.node.NodeTraversalException
- thrown if, and only if, a RuntimeException
is thrown by the current NodeHierarchicalVisitor
java.lang.NullPointerException
- thrown if, and only if, nodeHierarchicalVisitor
is null
public boolean equals(java.lang.Object object)
true
if, and only if, object
is an instance of Block
, and that Block
instance is equal to this Block
instance, false
otherwise.equals
in class java.lang.Object
object
- an Object
to compare to this Block
instance for equalitytrue
if, and only if, object
is an instance of Block
, and that Block
instance is equal to this Block
instance, false
otherwisepublic boolean isIterationStatement()
true
if, and only if, this Statement
is an iteration statement, false
otherwise.
This implementation returns false
, as a Block
is not an iteration statement.
isIterationStatement
in interface Statement
isIterationStatement
in interface StatementNoShortIf
true
if, and only if, this Statement
is an iteration statement, false
otherwisepublic int hashCode()
Block
instance.hashCode
in class java.lang.Object
Block
instancepublic java.util.List<BlockStatement> getBlockStatements()
List
with all currently added BlockStatement
s.
Any modifications made to the returned List
will not affect this Block
instance.
However, modifications made to any of the returned List
s elements, will indirectly affect this Block
instance.
List
with all currently added BlockStatement
spublic java.lang.String toString()
String
representation of this Block
instance.toString
in class java.lang.Object
String
representation of this Block
instancepublic void addComment(Comment comment)
Comment
to the end of this Block
instance.
If comment
is null
, a NullPointerException
will be thrown.
comment
- the Comment
to addjava.lang.NullPointerException
- thrown if, and only if, comment
is null
public void addBlockStatement(BlockStatement blockStatement)
BlockStatement
to the end of the BlockStatement
s section of this Block
instance.
If blockStatement
is null
, a NullPointerException
will be thrown.
blockStatement
- the BlockStatement
to addjava.lang.NullPointerException
- thrown if, and only if, blockStatement
is null
public void addWhiteSpace(WhiteSpace whiteSpace)
WhiteSpace
to the end of this Block
instance.
If whiteSpace
is null
, a NullPointerException
will be thrown.
whiteSpace
- the WhiteSpace
to addjava.lang.NullPointerException
- thrown if, and only if, whiteSpace
is null
public void removeComment(Comment comment)
Comment
from the end of this Block
instance, that is equal to comment
.
If comment
is null
, a NullPointerException
will be thrown.
comment
- the Comment
to removejava.lang.NullPointerException
- thrown if, and only if, comment
is null
public void removeBlockStatement(BlockStatement blockStatement)
BlockStatement
from the end of the BlockStatement
s section of this Block
instance, that is equal to blockStatement
.
If blockStatement
is null
, a NullPointerException
will be thrown.
blockStatement
- the BlockStatement
to removejava.lang.NullPointerException
- thrown if, and only if, blockStatement
is null
public void removeWhiteSpace(WhiteSpace whiteSpace)
WhiteSpace
from the end of this Block
instance, that is equal to whiteSpace
.
If whiteSpace
is null
, a NullPointerException
will be thrown.
whiteSpace
- the WhiteSpace
to removejava.lang.NullPointerException
- thrown if, and only if, whiteSpace
is null
public static Block newInstance()
Block
instance.Block
instance