Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
VariableDef
- All Known Implementing Classes:
ExpressionDef.CallInstanceMethod,ExpressionDef.CallStaticMethod,ExpressionDef.Condition,ExpressionDef.Constant,ExpressionDef.Convert,ExpressionDef.IfElse,ExpressionDef.NewArrayInitialized,ExpressionDef.NewArrayOfSize,ExpressionDef.NewInstance,ExpressionDef.Switch,ExpressionDef.SwitchYieldCase,VariableDef.Field,VariableDef.Local,VariableDef.MethodParameter,VariableDef.StaticField,VariableDef.This
public sealed interface ExpressionDef
permits ExpressionDef.CallInstanceMethod, ExpressionDef.CallStaticMethod, ExpressionDef.Condition, ExpressionDef.Constant, ExpressionDef.Convert, ExpressionDef.IfElse, ExpressionDef.NewArrayInitialized, ExpressionDef.NewArrayOfSize, ExpressionDef.NewInstance, ExpressionDef.Switch, ExpressionDef.SwitchYieldCase, VariableDef
The expression definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe call an instance method expression.static final recordThe call a static method expression.static final recordThe condition operator.static final recordThe constant expression.static final recordThe convert variable expression.static final recordThe if-else expression.static final recordThe new array expression.static final recordThe new array expression.static final recordThe new instance expression.static final recordThe switch expression.static final recordThe switch yield case expression. -
Method Summary
Modifier and TypeMethodDescriptiondefault ExpressionDefasCondition(String op, ExpressionDef expression) The condition of this variable.default StatementDefasConditionIf(StatementDef statement) The conditional statement based on this expression.default ExpressionDefasConditionIfElse(ExpressionDef expression, ExpressionDef elseExpression) The conditional if else expression.default StatementDefasConditionIfElse(StatementDef statement, StatementDef elseStatement) The conditional statement based on this expression.default ExpressionDef.SwitchasExpressionSwitch(TypeDef type, Map<ExpressionDef.Constant, ExpressionDef> cases) Turn this expression into an expression switch.default StatementDef.SwitchasStatementSwitch(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases) Turn this expression into a statement switch.static ExpressionDef.ConstantResolve a constant for the given type from the string.static @Nullable ExpressionDefResolve a constant for the given type from the string.default ExpressionDefConvert this variable to a different type.static ExpressionDef.Constantdefault VariableDef.FieldReference the field of this variable.default VariableDef.FieldReference the field of this variable.static ExpressionDef.NewInstanceinstantiate(ClassTypeDef type) The new instance expression.static ExpressionDef.NewInstanceinstantiate(ClassTypeDef type, List<ExpressionDef> values) The new instance expression.default ExpressionDef.CallInstanceMethodinvoke(io.micronaut.inject.ast.MethodElement methodElement, ExpressionDef... parameters) The call the instance method expression.default ExpressionDef.CallInstanceMethodinvoke(io.micronaut.inject.ast.MethodElement methodElement, List<ExpressionDef> parameters) The call the instance method expression.default ExpressionDef.CallInstanceMethodThe call the instance method expression.invoke(VariableDef instance, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.default ExpressionDef.CallInstanceMethodinvoke(String name, TypeDef returning, ExpressionDef... parameters) The call the instance method expression.default ExpressionDef.CallInstanceMethodinvoke(String name, TypeDef returning, List<ExpressionDef> parameters) The call the instance method expression.invokeStatic(ClassTypeDef typeDef, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.default ExpressionDefdefault ExpressionDefisNull()default StatementDef.DefineAndAssignTurn this expression into a new local variable.default StatementDefnewLocal(String name, Function<VariableDef, StatementDef> fn) Turn this expression into a new local variable.static ExpressionDef.Constantdefault StatementDefThe statement returning this expression.static ExpressionDef.Constanttype()The type of the expression.default StatementDef.WhilewhileLoop(StatementDef statement) Turn this expression into a while statement.
-
Method Details
-
asCondition
The condition of this variable.- Parameters:
op- The operatorexpression- The expression of this variable- Returns:
- The condition expression
- Since:
- 1.2
-
isNonNull
- Returns:
- Is non-null expression
- Since:
- 1.2
-
isNull
- Returns:
- Is null expression
- Since:
- 1.2
-
nullValue
- Returns:
- The null value expression
- Since:
- 1.2
-
trueValue
- Returns:
- The true value expression
- Since:
- 1.2
-
falseValue
- Returns:
- The true value expression
- Since:
- 1.2
-
returning
The statement returning this expression.- Returns:
- The statement returning this expression
-
asConditionIf
The conditional statement based on this expression.- Parameters:
statement- The statement- Returns:
- The statement returning this expression
- Since:
- 1.2
-
asConditionIfElse
The conditional statement based on this expression.- Parameters:
statement- The statementelseStatement- The else statement- Returns:
- The statement returning this expression
- Since:
- 1.2
-
asConditionIfElse
The conditional if else expression.- Parameters:
expression- The expressionelseExpression- The else expression- Returns:
- The statement returning this expression
- Since:
- 1.2
-
newLocal
Turn this expression into a new local variable.- Parameters:
name- The local name- Returns:
- A new local
- Since:
- 1.2
-
newLocal
Turn this expression into a new local variable.- Parameters:
name- The local namefn- The contextual function- Returns:
- A new local
- Since:
- 1.2
-
asExpressionSwitch
default ExpressionDef.Switch asExpressionSwitch(TypeDef type, Map<ExpressionDef.Constant, ExpressionDef> cases) Turn this expression into an expression switch.- Parameters:
type- The expression typecases- The cases- Returns:
- A new switch expression
- Since:
- 1.2
-
asStatementSwitch
default StatementDef.Switch asStatementSwitch(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases) Turn this expression into a statement switch.- Parameters:
type- The expression typecases- The cases- Returns:
- A new switch expression
- Since:
- 1.2
-
whileLoop
Turn this expression into a while statement.- Parameters:
statement- The statement- Returns:
- A new switch expression
- Since:
- 1.2
-
convert
Convert this variable to a different type.- Parameters:
typeDef- The type- Returns:
- the convert expression
- Since:
- 1.2
-
field
Reference the field of this variable.- Parameters:
fieldName- The field typetypeDef- Teh field type- Returns:
- The field variable
- Since:
- 1.2
-
field
Reference the field of this variable.- Parameters:
fieldDef- The field definition- Returns:
- The field variable
- Since:
- 1.2
-
invoke
The call the instance method expression.- Parameters:
methodDef- The method- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.CallInstanceMethod invoke(String name, TypeDef returning, ExpressionDef... parameters) The call the instance method expression.- Parameters:
name- The method nameparameters- The parametersreturning- The returning- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.CallInstanceMethod invoke(String name, TypeDef returning, List<ExpressionDef> parameters) The call the instance method expression.- Parameters:
name- The method nameparameters- The parametersreturning- The returning- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.CallInstanceMethod invoke(io.micronaut.inject.ast.MethodElement methodElement, ExpressionDef... parameters) The call the instance method expression.- Parameters:
methodElement- The method elementparameters- The parameters- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.CallInstanceMethod invoke(io.micronaut.inject.ast.MethodElement methodElement, List<ExpressionDef> parameters) The call the instance method expression.- Parameters:
methodElement- The method elementparameters- The parameters- Returns:
- The call to the instance method
- Since:
- 1.2
-
constant
@Nullable static @Nullable ExpressionDef constant(io.micronaut.inject.ast.ClassElement type, TypeDef typeDef, @Nullable @Nullable Object value) Resolve a constant for the given type from the string.- Parameters:
type- The typetypeDef- The type defvalue- The string value- Returns:
- The constant
- Throws:
IllegalArgumentException- if the constant is not supported.
-
constant
Resolve a constant for the given type from the string.- Parameters:
value- The string value- Returns:
- The constant
- Throws:
IllegalArgumentException- if the constant is not supported.- Since:
- 1.2
-
type
TypeDef type()The type of the expression.- Returns:
- The type
-
instantiate
The new instance expression.- Parameters:
type- The type- Returns:
- The new instance
-
instantiate
The new instance expression.- Parameters:
type- The typevalues- The constructor values- Returns:
- The new instance
-
invoke
static ExpressionDef.CallInstanceMethod invoke(VariableDef instance, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.- Parameters:
instance- The instancename- The method nameparameters- The parametersreturning- The returning- Returns:
- The call to the instance method
-
invokeStatic
static ExpressionDef.CallStaticMethod invokeStatic(ClassTypeDef typeDef, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.- Parameters:
typeDef- The class type defname- The method nameparameters- The parametersreturning- The returning- Returns:
- The call to the static method
-