Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
ExpressionDef.ConditionExpressionDef,VariableDef
- All Known Implementing Classes:
ExpressionDef.And,ExpressionDef.ArrayElement,ExpressionDef.Cast,ExpressionDef.ComparisonOperation,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.MathBinaryOperation,ExpressionDef.MathUnaryOperation,ExpressionDef.NewArrayInitialized,ExpressionDef.NewArrayOfSize,ExpressionDef.NewInstance,ExpressionDef.NotEqualsReferentially,ExpressionDef.NotEqualsStructurally,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.ArrayElement, ExpressionDef.Cast, ExpressionDef.ConditionExpressionDef, ExpressionDef.Constant, ExpressionDef.GetPropertyValue, ExpressionDef.IfElse, ExpressionDef.InstanceOf, ExpressionDef.InvokeGetClassMethod, ExpressionDef.InvokeHashCodeMethod, ExpressionDef.InvokeInstanceMethod, ExpressionDef.InvokeStaticMethod, ExpressionDef.MathBinaryOperation, ExpressionDef.MathUnaryOperation, 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 and condition.static final recordThe get array element expression.static final recordThe cast expression.static final recordThe condition operation.static interfaceThe conditional expression.static final recordThe constant expression.static final recordThe referential equals expression.static final recordThe structurally equals expression.static final recordThe get property value expression.static final recordThe if-else expression.static final recordThe instance of expression.static final recordThe get class expression.static final recordThe get hashCode expression.static final recordThe call an instance method expression.static final recordThe call a static method expression.static final recordThe IS FALSE condition.static final recordThe IS NOT NULL condition.static final recordThe IS NULL condition.static final recordThe IS TRUE condition.static final recordThe binary math operation.static final recordThe unary math operation.static final recordThe new array expression.static final recordThe new array expression.static final recordThe new instance expression.static final recordThe referential non-equals expression.static final recordThe structurally equals expression.static final recordThe or condition.static final recordThe switch expression.static final recordThe switch yield case expression. -
Method Summary
Modifier and TypeMethodDescriptiondefault ExpressionDef.ArrayElementarrayElement(int index) Check an array element.default ExpressionDef.ArrayElementarrayElement(ExpressionDef index) Check an array element.default ExpressionDef.SwitchasExpressionSwitch(TypeDef type, Map<ExpressionDef.Constant, ? extends ExpressionDef> cases, ExpressionDef defaultCase) Turn this expression into an expression switch.default StatementDefasStatementSwitch(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases) Turn this expression into a statement switch.default StatementDef.SwitchasStatementSwitch(TypeDef type, Map<ExpressionDef.Constant, StatementDef> cases, StatementDef defaultCase) Turn this expression into a statement switch.default ExpressionDef.CastCast expression to a different type.default ExpressionDef.CastCast expression to a different type.compare(ExpressionDef.ComparisonOperation.OpType op, ExpressionDef expression) The compare condition expression.static ExpressionDef.Constantconstant(boolean value) A new constant.static ExpressionDef.Constantconstant(char value) A new constant.static ExpressionDef.Constantconstant(double value) A new constant.static ExpressionDef.Constantconstant(float value) A new constant.static ExpressionDef.Constantconstant(int value) A new constant.static ExpressionDef.Constantconstant(long value) A new constant.static ExpressionDef.ConstantA new constant.static @Nullable ExpressionDefResolve a constant for the given type from the string.default StatementDef.ThrowdoThrow()Throw an exception.equalsReferentially(ExpressionDef other) The referentially equals (==) of this expression and the other expression.default ExpressionDef.EqualsStructurallyequalsStructurally(ExpressionDef other) The structurally equalsObject.equals(Object)of this expression and the other expression.static ExpressionDef.Constantdefault VariableDef.Fieldfield(io.micronaut.inject.ast.FieldElement fieldElement) Reference the field of this variable.default VariableDef.FieldReference the field of this variable.default VariableDef.FieldReference the field of this variable.default ExpressionDef.GetPropertyValuegetPropertyValue(io.micronaut.inject.ast.PropertyElement propertyElement) The get property value expression.default ExpressionDefifFalse(ExpressionDef ifExpression, ExpressionDef elseExpression) Is false - if / else expression.default StatementDefifFalse(StatementDef ifStatement) Is false - if statement.default StatementDefifFalse(StatementDef ifStatement, StatementDef elseStatement) Is false - if / else statement.default ExpressionDefifNonNull(ExpressionDef ifExpression, ExpressionDef elseExpression) Is not null - if / else expression.default StatementDefifNonNull(StatementDef ifStatement) Is not null - if statement.default StatementDefifNonNull(StatementDef ifStatement, StatementDef elseStatement) Is not null - if / else statement.default ExpressionDefifNull(ExpressionDef ifExpression, ExpressionDef elseExpression) Is null - if / else expression.default StatementDefifNull(StatementDef ifStatement) Is null - if statement.default StatementDefifNull(StatementDef ifStatement, StatementDef elseStatement) Is null - if / else statement.default ExpressionDefifTrue(ExpressionDef ifExpression, ExpressionDef elseExpression) Is true - if / else expression.default StatementDefifTrue(StatementDef ifStatement) Is true - if statement.default StatementDefifTrue(StatementDef ifStatement, StatementDef elseStatement) Is true - if / else statement.default ExpressionDef.InstanceOfinstanceOf(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 ExpressionDefmath(ExpressionDef.MathBinaryOperation.OpType op, ExpressionDef expression) The math binary operation of this variable.default ExpressionDefThe math unary operation of this variable.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.The referentially not-equals (!=) of this expression and the other expression.The structurally not-equals !Object.equals(Object)of this expression and the other expression.static ExpressionDef.Constantstatic ExpressionDef.ConstantprimitiveConstant(Object value) Resolve a constant for the given type from the string.default 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
-
arrayElement
Check an array element.- Parameters:
index- The index- Returns:
- The array element
- Since:
- 1.5
-
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
-
compare
default ExpressionDef.ConditionExpressionDef compare(ExpressionDef.ComparisonOperation.OpType op, ExpressionDef expression) The compare condition expression.- Parameters:
op- The operatorexpression- The expression of this variable- Returns:
- The condition expression
- Since:
- 1.2
-
math
The math binary operation of this variable.- Parameters:
op- The operatorexpression- The expression of this variable- Returns:
- The math expression
- Since:
- 1.2
-
math
The math unary operation of this variable.- Parameters:
op- The operator- Returns:
- The math expression
- Since:
- 1.5
-
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
-
notEqualsStructurally
The structurally not-equals !Object.equals(Object)of this expression and the other expression.- Parameters:
other- The other expression to compare with- Returns:
- The equals expression
- Since:
- 1.5
-
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
-
notEqualsReferentially
The referentially not-equals (!=) of this expression and the other expression.- Parameters:
other- The other expression to compare with- Returns:
- The equals expression
- Since:
- 1.5
-
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
-