Package io.micronaut.sourcegen.model
Interface ExpressionDef
- All Known Subinterfaces:
VariableDef
- All Known Implementing Classes:
ExpressionDef.And,ExpressionDef.CallInstanceMethod,ExpressionDef.CallStaticMethod,ExpressionDef.Cast,ExpressionDef.Condition,ExpressionDef.Constant,ExpressionDef.Convert,ExpressionDef.EqualsReferentially,ExpressionDef.EqualsStructurally,ExpressionDef.GetPropertyValue,ExpressionDef.IfElse,ExpressionDef.InvokeGetClassMethod,ExpressionDef.InvokeHashCodeMethod,ExpressionDef.NewArrayInitialized,ExpressionDef.NewArrayOfSize,ExpressionDef.NewInstance,ExpressionDef.Or,ExpressionDef.Switch,ExpressionDef.SwitchYieldCase,TypeDef.Primitive.PrimitiveInstance,VariableDef.Field,VariableDef.Local,VariableDef.MethodParameter,VariableDef.StaticField,VariableDef.This
public sealed interface ExpressionDef
permits ExpressionDef.And, ExpressionDef.CallInstanceMethod, ExpressionDef.CallStaticMethod, ExpressionDef.Cast, ExpressionDef.Condition, ExpressionDef.Constant, ExpressionDef.Convert, ExpressionDef.EqualsReferentially, ExpressionDef.EqualsStructurally, ExpressionDef.InvokeGetClassMethod, ExpressionDef.GetPropertyValue, ExpressionDef.InvokeHashCodeMethod, ExpressionDef.IfElse, ExpressionDef.NewArrayInitialized, ExpressionDef.NewArrayOfSize, ExpressionDef.NewInstance, ExpressionDef.Or, ExpressionDef.Switch, ExpressionDef.SwitchYieldCase, TypeDef.Primitive.PrimitiveInstance, VariableDef
The expression definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe and condition.static final recordThe call an instance method expression.static final recordThe call a static method expression.static final recordThe cast expression.static final recordThe condition operator.static final recordThe constant expression.static final recordThe convert variable 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 get class expression.static final recordThe get hashCode expression.static final recordThe new array expression.static final recordThe new array expression.static final recordThe new instance expression.static final recordThe or condition.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 ExpressionDefasConditionAnd(ExpressionDef expression) The and 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 ExpressionDefasConditionOr(ExpressionDef expression) The or condition of this variable.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.default ExpressionDef.CastCast expression to a different type.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.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.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.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<? extends ExpressionDef> parameters) The call the instance method expression.The invocation of theObject.getClass()} or equivalent method for the expression.The invocation of theObject.hashCode()or equivalent method for the 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
-
asConditionAnd
The and condition of this variable.- Parameters:
expression- The expression of this variable- Returns:
- The "and" condition expression
- Since:
- 1.3
-
asConditionOr
The or condition of this variable.- Parameters:
expression- The expression of this variable- Returns:
- The "or" condition expression
- Since:
- 1.3
-
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
-
cast
Cast expression to a different type.- Parameters:
type- The type to cast to- Returns:
- The cast 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<? extends 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
-
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
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
-