Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
ExpressionDef.ConditionExpressionDef
,VariableDef
- All Known Implementing Classes:
ExpressionDef.And
,ExpressionDef.ArrayElement
,ExpressionDef.Cast
,ExpressionDef.Condition
,ExpressionDef.Constant
,ExpressionDef.EqualsReferentially
,ExpressionDef.EqualsStructurally
,ExpressionDef.GetPropertyValue
,ExpressionDef.IfElse
,ExpressionDef.InstanceOf
,ExpressionDef.InvokeGetClassMethod
,ExpressionDef.InvokeHashCodeMethod
,ExpressionDef.InvokeInstanceMethod
,ExpressionDef.InvokeStaticMethod
,ExpressionDef.IsFalse
,ExpressionDef.IsNotNull
,ExpressionDef.IsNull
,ExpressionDef.IsTrue
,ExpressionDef.MathOp
,ExpressionDef.NewArrayInitialized
,ExpressionDef.NewArrayOfSize
,ExpressionDef.NewInstance
,ExpressionDef.Or
,ExpressionDef.Switch
,ExpressionDef.SwitchYieldCase
,VariableDef.ExceptionVar
,VariableDef.Field
,VariableDef.Local
,VariableDef.MethodParameter
,VariableDef.StaticField
,VariableDef.Super
,VariableDef.This
public sealed interface ExpressionDef
permits ExpressionDef.Cast, ExpressionDef.ConditionExpressionDef, ExpressionDef.Constant, ExpressionDef.ArrayElement, ExpressionDef.GetPropertyValue, ExpressionDef.IfElse, ExpressionDef.InstanceOf, ExpressionDef.InvokeGetClassMethod, ExpressionDef.InvokeHashCodeMethod, ExpressionDef.InvokeInstanceMethod, ExpressionDef.InvokeStaticMethod, ExpressionDef.MathOp, ExpressionDef.NewArrayInitialized, ExpressionDef.NewArrayOfSize, ExpressionDef.NewInstance, ExpressionDef.Switch, ExpressionDef.SwitchYieldCase, VariableDef
The expression definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
The and condition.static final record
The get array element expression.static final record
The cast expression.static final record
The condition operator.static interface
The conditional expression.static final record
The constant expression.static final record
The referential equals expression.static final record
The structurally equals expression.static final record
The get property value expression.static final record
The if-else expression.static final record
The instance of expression.static final record
The get class expression.static final record
The get hashCode expression.static final record
The call an instance method expression.static final record
The call a static method expression.static final record
The IS FALSE condition.static final record
The IS NOT NULL condition.static final record
The IS NULL condition.static final record
The IS TRUE condition.static final record
The math operator.static final record
The new array expression.static final record
The new array expression.static final record
The new instance expression.static final record
The or condition.static final record
The switch expression.static final record
The switch yield case expression. -
Method Summary
Modifier and TypeMethodDescriptiondefault ExpressionDef.ArrayElement
arrayElement
(int index) Check an array element.asCondition
(String op, ExpressionDef expression) The condition of this variable.default ExpressionDef.Switch
asExpressionSwitch
(TypeDef type, Map<ExpressionDef.Constant, ? extends ExpressionDef> cases, ExpressionDef defaultCase) Turn this expression into an expression switch.default StatementDef
asStatementSwitch
(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases) Turn this expression into a statement switch.default StatementDef.Switch
asStatementSwitch
(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases, StatementDef defaultCase) Turn this expression into a statement switch.default ExpressionDef.Cast
Cast expression to a different type.default ExpressionDef.Cast
Cast expression to a different type.static ExpressionDef.Constant
constant
(boolean value) A new constant.static ExpressionDef.Constant
constant
(char value) A new constant.static ExpressionDef.Constant
constant
(double value) A new constant.static ExpressionDef.Constant
constant
(float value) A new constant.static ExpressionDef.Constant
constant
(int value) A new constant.static ExpressionDef.Constant
constant
(long value) A new constant.static ExpressionDef.Constant
A new constant.static @Nullable ExpressionDef
Resolve a constant for the given type from the string.default StatementDef.Throw
doThrow()
Throw an exception.equalsReferentially
(ExpressionDef other) The referentially equals (==) of this expression and the other expression.default ExpressionDef.EqualsStructurally
equalsStructurally
(ExpressionDef other) The structurally equalsObject.equals(Object)
of this expression and the other expression.static ExpressionDef.Constant
default VariableDef.Field
field
(io.micronaut.inject.ast.FieldElement fieldElement) Reference the field of this variable.default VariableDef.Field
Reference the field of this variable.default VariableDef.Field
Reference the field of this variable.default ExpressionDef.GetPropertyValue
getPropertyValue
(io.micronaut.inject.ast.PropertyElement propertyElement) The get property value expression.default ExpressionDef
ifFalse
(ExpressionDef ifExpression, ExpressionDef elseExpression) Is false - if / else expression.default StatementDef
ifFalse
(StatementDef ifStatement) Is false - if statement.default StatementDef
ifFalse
(StatementDef ifStatement, StatementDef elseStatement) Is false - if / else statement.default ExpressionDef
ifNonNull
(ExpressionDef ifExpression, ExpressionDef elseExpression) Is not null - if / else expression.default StatementDef
ifNonNull
(StatementDef ifStatement) Is not null - if statement.default StatementDef
ifNonNull
(StatementDef ifStatement, StatementDef elseStatement) Is not null - if / else statement.default ExpressionDef
ifNull
(ExpressionDef ifExpression, ExpressionDef elseExpression) Is null - if / else expression.default StatementDef
ifNull
(StatementDef ifStatement) Is null - if statement.default StatementDef
ifNull
(StatementDef ifStatement, StatementDef elseStatement) Is null - if / else statement.default ExpressionDef
ifTrue
(ExpressionDef ifExpression, ExpressionDef elseExpression) Is true - if / else expression.default StatementDef
ifTrue
(StatementDef ifStatement) Is true - if statement.default StatementDef
ifTrue
(StatementDef ifStatement, StatementDef elseStatement) Is true - if / else statement.default ExpressionDef.InstanceOf
instanceOf
(ClassTypeDef instanceType) Check if the instance is of the type.invoke
(io.micronaut.inject.ast.MethodElement methodElement, ExpressionDef... values) The call the instance method expression.invoke
(io.micronaut.inject.ast.MethodElement methodElement, List<? extends ExpressionDef> values) The call the instance method expression.invoke
(MethodDef method, ExpressionDef... values) The call the instance method expression.invoke
(MethodDef methodDef, List<? extends ExpressionDef> values) The call the instance method expression.invoke
(Method method, ExpressionDef... values) The invoke the method defined by the reflection.invoke
(Method method, List<? extends ExpressionDef> values) The invoke the method defined by the reflection.invoke
(String name, TypeDef returning, ExpressionDef... values) The call the instance method expression.invoke
(String name, TypeDef returning, List<? extends ExpressionDef> values) The call the instance method expression.invoke
(String name, List<TypeDef> parameterTypes, TypeDef returning, List<? extends ExpressionDef> values) The call the instance method expression.invokeConstructor
(ExpressionDef... values) The invoke constructor expression.invokeConstructor
(MethodDef constructor, ExpressionDef... values) The new instance expression.invokeConstructor
(MethodDef constructor, List<? extends ExpressionDef> values) The new instance expression.invokeConstructor
(Constructor<?> constructor, ExpressionDef... values) The new instance expression.invokeConstructor
(Constructor<?> constructor, List<? extends ExpressionDef> values) The new instance expression.invokeConstructor
(List<? extends ExpressionDef> values) The invoke constructor expression.invokeConstructor
(List<TypeDef> parameterTypes, ExpressionDef... values) The invoke constructor expression.invokeConstructor
(List<TypeDef> parameterTypes, List<? extends ExpressionDef> values) The invoke constructor expression.The invocation of theObject.getClass()
} or equivalent method for the expression.The invocation of theObject.hashCode()
or equivalent method for the expression.isFalse()
isNull()
isTrue()
default ExpressionDef
math
(String op, ExpressionDef expression) The math operation of this variable.default StatementDef.DefineAndAssign
Turn this expression into a new local variable.default StatementDef
newLocal
(String name, Function<VariableDef, StatementDef> fn) Turn this expression into a new local variable.static ExpressionDef.Constant
static ExpressionDef.Constant
primitiveConstant
(Object value) Resolve a constant for the given type from the string.default StatementDef
The statement returning this expression.static ExpressionDef.Constant
type()
The type of the expression.default StatementDef.While
whileLoop
(StatementDef statement) Turn this expression into a while statement.
-
Method Details
-
arrayElement
Check an array element.- Parameters:
index
- The index- Returns:
- The array element
- Since:
- 1.5
-
instanceOf
Check if the instance is of the type.- Parameters:
instanceType
- The instance type- Returns:
- The instance of expression
- Since:
- 1.5
-
doThrow
Throw an exception.- Returns:
- The throw statement
-
asCondition
The condition of this variable.- Parameters:
op
- The operatorexpression
- The expression of this variable- Returns:
- The condition expression
- Since:
- 1.2
-
math
The math operation 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
-
ifNonNull
Is not null - if / else expression.- Parameters:
ifExpression
- If expressionelseExpression
- Else expression- Returns:
- Is not null expression
- Since:
- 1.5
-
ifNonNull
Is not null - if statement.- Parameters:
ifStatement
- If statement- Returns:
- Is not null statement
- Since:
- 1.5
-
ifNonNull
Is not null - if / else statement.- Parameters:
ifStatement
- If statementelseStatement
- Else statement- Returns:
- Is not null statement
- Since:
- 1.5
-
isNull
- Returns:
- Is null expression
- Since:
- 1.2
-
ifNull
Is null - if / else expression.- Parameters:
ifExpression
- If expressionelseExpression
- Else expression- Returns:
- Is null expression
- Since:
- 1.5
-
ifNull
Is null - if statement.- Parameters:
ifStatement
- If statement- Returns:
- Is null statement
- Since:
- 1.5
-
ifNull
Is null - if / else statement.- Parameters:
ifStatement
- If statementelseStatement
- Else statement- Returns:
- Is null statement
- Since:
- 1.5
-
isTrue
- Returns:
- Is true expression
- Since:
- 1.5
-
ifTrue
Is true - if / else expression.- Parameters:
ifExpression
- If expressionelseExpression
- Else expression- Returns:
- Is true expression
- Since:
- 1.5
-
ifTrue
Is true - if statement.- Parameters:
ifStatement
- If statement- Returns:
- Is true statement
- Since:
- 1.5
-
ifTrue
Is true - if / else statement.- Parameters:
ifStatement
- If statementelseStatement
- Else statement- Returns:
- Is true statement
- Since:
- 1.5
-
isFalse
- Returns:
- Is false expression
- Since:
- 1.5
-
ifFalse
Is false - if / else expression.- Parameters:
ifExpression
- If expressionelseExpression
- Else expression- Returns:
- Is false expression
- Since:
- 1.5
-
ifFalse
Is false - if statement.- Parameters:
ifStatement
- If statement- Returns:
- Is null statement
- Since:
- 1.5
-
ifFalse
Is false - if / else statement.- Parameters:
ifStatement
- If statementelseStatement
- Else statement- Returns:
- Is false statement
- Since:
- 1.5
-
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
-
cast
Cast expression to a different type.- Parameters:
type
- The type to cast to- Returns:
- The cast expression
-
cast
Cast expression to a different type.- Parameters:
type
- The type to cast to- Returns:
- The cast expression
- Since:
- 1.5
-
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
-
asStatementSwitch
default StatementDef 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
-
asExpressionSwitch
default ExpressionDef.Switch asExpressionSwitch(TypeDef type, Map<ExpressionDef.Constant, ? extends ExpressionDef> cases, ExpressionDef defaultCase) Turn this expression into an expression switch.- Parameters:
type
- The expression typecases
- The casesdefaultCase
- The default cae- Returns:
- A new switch expression
- Since:
- 1.5
-
asStatementSwitch
default StatementDef.Switch asStatementSwitch(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases, StatementDef defaultCase) Turn this expression into a statement switch.- Parameters:
type
- The expression typecases
- The casesdefaultCase
- The default case- 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
-
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
-
field
Reference the field of this variable.- Parameters:
fieldElement
- The field definition- Returns:
- The field variable
- Since:
- 1.5
-
invokeConstructor
The invoke constructor expression.- Parameters:
values
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invokeConstructor
The invoke constructor expression.- Parameters:
values
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(List<TypeDef> parameterTypes, ExpressionDef... values) The invoke constructor expression.- Parameters:
parameterTypes
- The parameterTypesvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(List<TypeDef> parameterTypes, List<? extends ExpressionDef> values) The invoke constructor expression.- Parameters:
parameterTypes
- The parameterTypesvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(Constructor<?> constructor, ExpressionDef... values) The new instance expression.- Parameters:
constructor
- The constructorvalues
- The constructor values- Returns:
- The new instance
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(Constructor<?> constructor, List<? extends ExpressionDef> values) The new instance expression.- Parameters:
constructor
- The constructorvalues
- The constructor values- Returns:
- The new instance
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(MethodDef constructor, ExpressionDef... values) The new instance expression.- Parameters:
constructor
- The constructorvalues
- The constructor values- Returns:
- The new instance
-
invokeConstructor
default ExpressionDef.InvokeInstanceMethod invokeConstructor(MethodDef constructor, List<? extends ExpressionDef> values) The new instance expression.- Parameters:
constructor
- The constructorvalues
- The constructor values- Returns:
- The new instance
-
invoke
The call the instance method expression.- Parameters:
method
- The methodvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(MethodDef methodDef, List<? extends ExpressionDef> values) The call the instance method expression.- Parameters:
methodDef
- The methodvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invoke
The invoke the method defined by the reflection.- Parameters:
method
- The methodvalues
- The parameters- Returns:
- The invoke method expression
- Since:
- 1.5
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(Method method, List<? extends ExpressionDef> values) The invoke the method defined by the reflection.- Parameters:
method
- The methodvalues
- The parameters- Returns:
- The invoke method expression
- Since:
- 1.5
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(String name, TypeDef returning, ExpressionDef... values) The call the instance method expression.- Parameters:
name
- The method namereturning
- The returningvalues
- The parameters- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(String name, TypeDef returning, List<? extends ExpressionDef> values) The call the instance method expression.- Parameters:
name
- The method namereturning
- The returningvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(String name, List<TypeDef> parameterTypes, TypeDef returning, List<? extends ExpressionDef> values) The call the instance method expression.- Parameters:
name
- The method nameparameterTypes
- The parameterTypesreturning
- The returningvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.5
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(io.micronaut.inject.ast.MethodElement methodElement, ExpressionDef... values) The call the instance method expression.- Parameters:
methodElement
- The method elementvalues
- The values- Returns:
- The call to the instance method
- Since:
- 1.2
-
invoke
default ExpressionDef.InvokeInstanceMethod invoke(io.micronaut.inject.ast.MethodElement methodElement, List<? extends ExpressionDef> values) The call the instance method expression.- Parameters:
methodElement
- The method elementvalues
- The parameters- Returns:
- The call to the instance method
- Since:
- 1.2
-
invokeHashCode
The invocation of theObject.hashCode()
or equivalent method for the expression.- Returns:
- The hash code invocation
- Since:
- 1.2
-
invokeGetClass
The invocation of theObject.getClass()
} or equivalent method for the expression.- Returns:
- The get class invocation
- Since:
- 1.2
-
equalsStructurally
The structurally equalsObject.equals(Object)
of this expression and the other expression.- Parameters:
other
- The other expression to compare with- Returns:
- The equals expression
- Since:
- 1.3
-
equalsReferentially
The referentially equals (==) of this expression and the other expression.- Parameters:
other
- The other expression to compare with- Returns:
- The equals expression
- Since:
- 1.3
-
getPropertyValue
default ExpressionDef.GetPropertyValue getPropertyValue(io.micronaut.inject.ast.PropertyElement propertyElement) The get property value expression.- Parameters:
propertyElement
- The property element- Returns:
- The get property value expression
- Since:
- 1.3
-
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
A new constant.- Parameters:
value
- The string value- Returns:
- The constant
- Throws:
IllegalArgumentException
- if the constant is not supported.- Since:
- 1.2
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.5
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.5
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.5
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.4
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.5
-
constant
A new constant.- Parameters:
value
- The value- Returns:
- The constant
- Since:
- 1.5
-
primitiveConstant
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
-