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

The expression definition.
Since:
1.0
Author:
Denis Stepanov
  • Method Details

    • arrayElement

      default ExpressionDef.ArrayElement arrayElement(int index)
      Check an array element.
      Parameters:
      index - The index
      Returns:
      The array element
      Since:
      1.5
    • instanceOf

      default ExpressionDef.InstanceOf instanceOf(ClassTypeDef instanceType)
      Check if the instance is of the type.
      Parameters:
      instanceType - The instance type
      Returns:
      The instance of expression
      Since:
      1.5
    • doThrow

      default StatementDef.Throw doThrow()
      Throw an exception.
      Returns:
      The throw statement
    • asCondition

      default ExpressionDef.ConditionExpressionDef asCondition(String op, ExpressionDef expression)
      The condition of this variable.
      Parameters:
      op - The operator
      expression - The expression of this variable
      Returns:
      The condition expression
      Since:
      1.2
    • math

      default ExpressionDef math(String op, ExpressionDef expression)
      The math operation of this variable.
      Parameters:
      op - The operator
      expression - The expression of this variable
      Returns:
      The condition expression
      Since:
      1.2
    • isNonNull

      Returns:
      Is non-null expression
      Since:
      1.2
    • ifNonNull

      default ExpressionDef ifNonNull(ExpressionDef ifExpression, ExpressionDef elseExpression)
      Is not null - if / else expression.
      Parameters:
      ifExpression - If expression
      elseExpression - Else expression
      Returns:
      Is not null expression
      Since:
      1.5
    • ifNonNull

      default StatementDef ifNonNull(StatementDef ifStatement)
      Is not null - if statement.
      Parameters:
      ifStatement - If statement
      Returns:
      Is not null statement
      Since:
      1.5
    • ifNonNull

      default StatementDef ifNonNull(StatementDef ifStatement, StatementDef elseStatement)
      Is not null - if / else statement.
      Parameters:
      ifStatement - If statement
      elseStatement - Else statement
      Returns:
      Is not null statement
      Since:
      1.5
    • isNull

      Returns:
      Is null expression
      Since:
      1.2
    • ifNull

      default ExpressionDef ifNull(ExpressionDef ifExpression, ExpressionDef elseExpression)
      Is null - if / else expression.
      Parameters:
      ifExpression - If expression
      elseExpression - Else expression
      Returns:
      Is null expression
      Since:
      1.5
    • ifNull

      default StatementDef ifNull(StatementDef ifStatement)
      Is null - if statement.
      Parameters:
      ifStatement - If statement
      Returns:
      Is null statement
      Since:
      1.5
    • ifNull

      default StatementDef ifNull(StatementDef ifStatement, StatementDef elseStatement)
      Is null - if / else statement.
      Parameters:
      ifStatement - If statement
      elseStatement - Else statement
      Returns:
      Is null statement
      Since:
      1.5
    • isTrue

      Returns:
      Is true expression
      Since:
      1.5
    • ifTrue

      default ExpressionDef ifTrue(ExpressionDef ifExpression, ExpressionDef elseExpression)
      Is true - if / else expression.
      Parameters:
      ifExpression - If expression
      elseExpression - Else expression
      Returns:
      Is true expression
      Since:
      1.5
    • ifTrue

      default StatementDef ifTrue(StatementDef ifStatement)
      Is true - if statement.
      Parameters:
      ifStatement - If statement
      Returns:
      Is true statement
      Since:
      1.5
    • ifTrue

      default StatementDef ifTrue(StatementDef ifStatement, StatementDef elseStatement)
      Is true - if / else statement.
      Parameters:
      ifStatement - If statement
      elseStatement - Else statement
      Returns:
      Is true statement
      Since:
      1.5
    • isFalse

      Returns:
      Is false expression
      Since:
      1.5
    • ifFalse

      default ExpressionDef ifFalse(ExpressionDef ifExpression, ExpressionDef elseExpression)
      Is false - if / else expression.
      Parameters:
      ifExpression - If expression
      elseExpression - Else expression
      Returns:
      Is false expression
      Since:
      1.5
    • ifFalse

      default StatementDef ifFalse(StatementDef ifStatement)
      Is false - if statement.
      Parameters:
      ifStatement - If statement
      Returns:
      Is null statement
      Since:
      1.5
    • ifFalse

      default StatementDef ifFalse(StatementDef ifStatement, StatementDef elseStatement)
      Is false - if / else statement.
      Parameters:
      ifStatement - If statement
      elseStatement - Else statement
      Returns:
      Is false statement
      Since:
      1.5
    • nullValue

      @NonNull static ExpressionDef.Constant nullValue()
      Returns:
      The null value expression
      Since:
      1.2
    • trueValue

      @NonNull static ExpressionDef.Constant trueValue()
      Returns:
      The true value expression
      Since:
      1.2
    • falseValue

      @NonNull static ExpressionDef.Constant falseValue()
      Returns:
      The true value expression
      Since:
      1.2
    • returning

      default StatementDef returning()
      The statement returning this expression.
      Returns:
      The statement returning this expression
    • cast

      @NonNull default ExpressionDef.Cast cast(TypeDef type)
      Cast expression to a different type.
      Parameters:
      type - The type to cast to
      Returns:
      The cast expression
    • cast

      @NonNull default ExpressionDef.Cast cast(Class<?> type)
      Cast expression to a different type.
      Parameters:
      type - The type to cast to
      Returns:
      The cast expression
      Since:
      1.5
    • newLocal

      default StatementDef.DefineAndAssign newLocal(String name)
      Turn this expression into a new local variable.
      Parameters:
      name - The local name
      Returns:
      A new local
      Since:
      1.2
    • newLocal

      default StatementDef newLocal(String name, Function<VariableDef,StatementDef> fn)
      Turn this expression into a new local variable.
      Parameters:
      name - The local name
      fn - 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 type
      cases - 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 type
      cases - The cases
      defaultCase - 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 type
      cases - The cases
      defaultCase - The default case
      Returns:
      A new switch expression
      Since:
      1.2
    • whileLoop

      default StatementDef.While whileLoop(StatementDef statement)
      Turn this expression into a while statement.
      Parameters:
      statement - The statement
      Returns:
      A new switch expression
      Since:
      1.2
    • field

      default VariableDef.Field field(String fieldName, TypeDef typeDef)
      Reference the field of this variable.
      Parameters:
      fieldName - The field type
      typeDef - Teh field type
      Returns:
      The field variable
      Since:
      1.2
    • field

      default VariableDef.Field field(FieldDef fieldDef)
      Reference the field of this variable.
      Parameters:
      fieldDef - The field definition
      Returns:
      The field variable
      Since:
      1.2
    • field

      default VariableDef.Field field(io.micronaut.inject.ast.FieldElement fieldElement)
      Reference the field of this variable.
      Parameters:
      fieldElement - The field definition
      Returns:
      The field variable
      Since:
      1.5
    • invokeConstructor

      default ExpressionDef.InvokeInstanceMethod invokeConstructor(ExpressionDef... values)
      The invoke constructor expression.
      Parameters:
      values - The values
      Returns:
      The call to the instance method
      Since:
      1.5
    • invokeConstructor

      default ExpressionDef.InvokeInstanceMethod invokeConstructor(List<? extends ExpressionDef> values)
      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 parameterTypes
      values - 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 parameterTypes
      values - 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 constructor
      values - 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 constructor
      values - The constructor values
      Returns:
      The new instance
    • invokeConstructor

      default ExpressionDef.InvokeInstanceMethod invokeConstructor(MethodDef constructor, ExpressionDef... values)
      The new instance expression.
      Parameters:
      constructor - The constructor
      values - 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 constructor
      values - The constructor values
      Returns:
      The new instance
    • invoke

      default ExpressionDef.InvokeInstanceMethod invoke(MethodDef method, ExpressionDef... values)
      The call the instance method expression.
      Parameters:
      method - The method
      values - 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 method
      values - The values
      Returns:
      The call to the instance method
      Since:
      1.5
    • invoke

      default ExpressionDef.InvokeInstanceMethod invoke(Method method, ExpressionDef... values)
      The invoke the method defined by the reflection.
      Parameters:
      method - The method
      values - 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 method
      values - 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 name
      returning - The returning
      values - 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 name
      returning - The returning
      values - 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 name
      parameterTypes - The parameterTypes
      returning - The returning
      values - 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 element
      values - 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 element
      values - The parameters
      Returns:
      The call to the instance method
      Since:
      1.2
    • invokeHashCode

      default ExpressionDef.InvokeHashCodeMethod invokeHashCode()
      The invocation of the Object.hashCode() or equivalent method for the expression.
      Returns:
      The hash code invocation
      Since:
      1.2
    • invokeGetClass

      default ExpressionDef.InvokeGetClassMethod invokeGetClass()
      The invocation of the Object.getClass()} or equivalent method for the expression.
      Returns:
      The get class invocation
      Since:
      1.2
    • equalsStructurally

      default ExpressionDef.EqualsStructurally equalsStructurally(ExpressionDef other)
      The structurally 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.3
    • equalsReferentially

      default ExpressionDef.EqualsReferentially equalsReferentially(ExpressionDef other)
      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 type
      typeDef - The type def
      value - The string value
      Returns:
      The constant
      Throws:
      IllegalArgumentException - if the constant is not supported.
    • constant

      @Nullable static ExpressionDef.Constant constant(@Nullable @Nullable Object value)
      A new constant.
      Parameters:
      value - The string value
      Returns:
      The constant
      Throws:
      IllegalArgumentException - if the constant is not supported.
      Since:
      1.2
    • constant

      static ExpressionDef.Constant constant(boolean value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.5
    • constant

      static ExpressionDef.Constant constant(int value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.5
    • constant

      static ExpressionDef.Constant constant(long value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.5
    • constant

      static ExpressionDef.Constant constant(double value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.4
    • constant

      static ExpressionDef.Constant constant(float value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.5
    • constant

      static ExpressionDef.Constant constant(char value)
      A new constant.
      Parameters:
      value - The value
      Returns:
      The constant
      Since:
      1.5
    • primitiveConstant

      @Nullable static ExpressionDef.Constant primitiveConstant(@NotNull Object value)
      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