Class JavaStatement
java.lang.Object
com.regnosys.rosetta.generator.java.statement.JavaStatement
- All Implemented Interfaces:
TargetLanguageRepresentation
- Direct Known Subclasses:
JavaAssignment,JavaBlock,JavaExpressionStatement,JavaIfThenElseStatement,JavaIfThenStatement,JavaLocalVariableDeclarationStatement,JavaReturnStatement
A representation of a statement in Java. Examples:
- a return statement `return foo;`
- a local variable declaration: `int x = 42;`
- an if-then statement: `if (cond) return foo;`
- a block of statements:
```
{
int x = 42;
if (cond) return foo;
return x;
}
```
Based on the Java specification: https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-BlockStatement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(JavaStatement other) Append the given statement to this one.prepend(JavaStatement other) toBlock()Convert this statement into a block enclosed by curly braces, if this statement is not already a block.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.regnosys.rosetta.generator.TargetLanguageRepresentation
appendTo
-
Constructor Details
-
JavaStatement
public JavaStatement()
-
-
Method Details
-
toBlock
Convert this statement into a block enclosed by curly braces, if this statement is not already a block. For example, given the statement `return x;`, the following block statement will be returned: ``` { return x; } ``` -
asStatementList
-
prepend
-
append
Append the given statement to this one. Behaves the same as `other.prepend(this)`. This operation flattens block statements. Examples: - given the statements `int x = 42;` and `return x;`, appending the latter to the former results in the following block: ``` { int x = 42; return x; } ``` - given a statement `int x = 42;` and a block ``` { int y = x + 1; return y; } ``` appending the latter to the former results in the following block: ``` { int x = 42; int y = x + 1; return y; } ```
-