Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
VariableDef
- All Known Implementing Classes:
ExpressionDef.CallInstanceMethod
,ExpressionDef.CallStaticMethod
,ExpressionDef.Constant
,ExpressionDef.Convert
,ExpressionDef.NewInstance
,VariableDef.Field
,VariableDef.Local
,VariableDef.MethodParameter
,VariableDef.StaticField
,VariableDef.This
public sealed interface ExpressionDef
permits ExpressionDef.CallInstanceMethod, ExpressionDef.CallStaticMethod, ExpressionDef.Constant, ExpressionDef.Convert, ExpressionDef.NewInstance, VariableDef
The expression definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
The call an instance method expression.static final record
The call a static method expression.static final record
The convert variable expression.static final record
The convert variable expression.static final record
The new instance expression. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable ExpressionDef
Resolve a constant for the given type from the string.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.type()
The type of the expression.
-
Method Details
-
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 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
-