Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
InstanceDef
,VariableDef
- All Known Implementing Classes:
ExpressionDef.CallInstanceMethod
,ExpressionDef.CallStaticMethod
,ExpressionDef.Condition
,ExpressionDef.Constant
,ExpressionDef.Convert
,ExpressionDef.IfElse
,ExpressionDef.NewInstance
,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.NewInstance, VariableDef
The expression definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
The call an instance method expression.static final record
The call a static method expression.static final record
The condition operator.static final record
The convert variable expression.static final record
The convert variable expression.static final record
The if-else expression.static final record
The new instance expression. -
Method Summary
Modifier and TypeMethodDescriptiondefault StatementDef
asConditionIf
(StatementDef statement) The conditional statement based on this expression.default ExpressionDef
asConditionIfElse
(ExpressionDef expression, ExpressionDef elseExpression) The conditional if else expression.default StatementDef
asConditionIfElse
(StatementDef statement, StatementDef elseStatement) The conditional statement based on this expression.static @Nullable ExpressionDef
Resolve a constant for the given type from the string.static @NonNull ExpressionDef
static ExpressionDef.NewInstance
instantiate
(ClassTypeDef type) The new instance expression.static ExpressionDef.NewInstance
instantiate
(ClassTypeDef type, List<ExpressionDef> values) The new instance expression.invoke
(VariableDef instance, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.invokeStatic
(ClassTypeDef typeDef, String name, List<ExpressionDef> parameters, TypeDef returning) The call the instance method expression.static @NonNull ExpressionDef
default StatementDef
The statement returning this expression.static @NonNull ExpressionDef
type()
The type of the expression.
-
Method Details
-
nullValue
- Returns:
- The null value expression
-
trueValue
- Returns:
- The true value expression
-
falseValue
- Returns:
- The true value expression
-
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
-
asConditionIfElse
The conditional statement based on this expression.- Parameters:
statement
- The statementelseStatement
- The else statement- Returns:
- The statement returning this expression
-
asConditionIfElse
The conditional if else expression.- Parameters:
expression
- The expressionelseExpression
- The else expression- Returns:
- The statement returning this expression
-
constant
@Nullable static @Nullable ExpressionDef constant(io.micronaut.inject.ast.ClassElement type, TypeDef typeDef, @Nullable @Nullable String stringValue) Resolve a constant for the given type from the string.- Parameters:
type
- The typetypeDef
- The type defstringValue
- The string value- Returns:
- The constant
- Throws:
IllegalArgumentException
- if the constant is not supported.
-
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
-