Class JavaBlockBuilder
java.lang.Object
com.regnosys.rosetta.generator.java.statement.builder.JavaStatementBuilder
com.regnosys.rosetta.generator.java.statement.builder.JavaBlockBuilder
Based on the Java specification: https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Block
Example:
```
{
int x = 42;
x
}
```
See `JavaStatementBuilder` for more documentation.
-
Constructor Summary
ConstructorsConstructorDescriptionJavaBlockBuilder(JavaStatementBuilder lastStatement) JavaBlockBuilder(JavaStatementList statements, JavaStatementBuilder lastStatement) -
Method Summary
Modifier and TypeMethodDescriptionIf this statement builder ends with multiple branches, assign all expressions to a new variable and return a new builder ending with that variable.complete(Function<JavaExpression, JavaStatement> completer) Complete this statement builder by mapping all expressions to a statement.completeAsAssignment(GeneratedIdentifier variableId) Complete this statement builder by assigning all expressions to a given variable.Complete this statement builder by ending all expressions with a semicolon.Complete this statement builder by returning all expressions.declareAsVariable(boolean isFinal, String variableId, JavaScope scope) Assign all expressions to a new variable, and return a new builder ending with that variable.Get the type of the last expression of this builder, or the least common supertype of all expressions in different branches of this builder.mapExpression(Function<JavaExpression, ? extends JavaStatementBuilder> mapper) Map all expressions contained in this builder to a new builder, and append the result.then(JavaBlockBuilder after, BiFunction<JavaExpression, JavaExpression, JavaStatementBuilder> combineExpressions, JavaScope scope) then(JavaStatementBuilder after, BiFunction<JavaExpression, JavaExpression, JavaStatementBuilder> combineExpressions, JavaScope scope) Append another statement builder to this one, and combine this expression with the other using the given operation.Convert this statement builder into a valid lambda body.Methods inherited from class com.regnosys.rosetta.generator.java.statement.builder.JavaStatementBuilder
mapExpressionIfNotNull
-
Constructor Details
-
JavaBlockBuilder
-
JavaBlockBuilder
-
-
Method Details
-
getExpressionType
Description copied from class:JavaStatementBuilderGet the type of the last expression of this builder, or the least common supertype of all expressions in different branches of this builder.- Specified by:
getExpressionTypein classJavaStatementBuilder
-
mapExpression
public JavaStatementBuilder mapExpression(Function<JavaExpression, ? extends JavaStatementBuilder> mapper) Description copied from class:JavaStatementBuilderMap all expressions contained in this builder to a new builder, and append the result. This will flatten Java block statements.- Specified by:
mapExpressionin classJavaStatementBuilder
-
then
public JavaStatementBuilder then(JavaStatementBuilder after, BiFunction<JavaExpression, JavaExpression, JavaStatementBuilder> combineExpressions, JavaScope scope) Description copied from class:JavaStatementBuilderAppend another statement builder to this one, and combine this expression with the other using the given operation.- Specified by:
thenin classJavaStatementBuilder
-
then
public JavaBlockBuilder then(JavaBlockBuilder after, BiFunction<JavaExpression, JavaExpression, JavaStatementBuilder> combineExpressions, JavaScope scope) -
complete
Description copied from class:JavaStatementBuilderComplete this statement builder by mapping all expressions to a statement.- Specified by:
completein classJavaStatementBuilder
-
completeAsReturn
Description copied from class:JavaStatementBuilderComplete this statement builder by returning all expressions.- Specified by:
completeAsReturnin classJavaStatementBuilder
-
completeAsExpressionStatement
Description copied from class:JavaStatementBuilderComplete this statement builder by ending all expressions with a semicolon.- Specified by:
completeAsExpressionStatementin classJavaStatementBuilder
-
completeAsAssignment
Description copied from class:JavaStatementBuilderComplete this statement builder by assigning all expressions to a given variable.- Specified by:
completeAsAssignmentin classJavaStatementBuilder
-
declareAsVariable
Description copied from class:JavaStatementBuilderAssign all expressions to a new variable, and return a new builder ending with that variable.- Specified by:
declareAsVariablein classJavaStatementBuilder
-
collapseToSingleExpression
Description copied from class:JavaStatementBuilderIf this statement builder ends with multiple branches, assign all expressions to a new variable and return a new builder ending with that variable. If this statement builder does not end in multiple branches, return itself unmodified.- Specified by:
collapseToSingleExpressionin classJavaStatementBuilder
-
toLambdaBody
Description copied from class:JavaStatementBuilderConvert this statement builder into a valid lambda body.- Specified by:
toLambdaBodyin classJavaStatementBuilder
-