Interface ExpressionDef

All Known Subinterfaces:
VariableDef
All Known Implementing Classes:
ExpressionDef.CallInstanceMethod, ExpressionDef.CallStaticMethod, ExpressionDef.Condition, ExpressionDef.Constant, ExpressionDef.Convert, ExpressionDef.IfElse, ExpressionDef.NewArrayInitialized, ExpressionDef.NewArrayOfSize, ExpressionDef.NewInstance, ExpressionDef.Switch, ExpressionDef.SwitchYieldCase, VariableDef.Field, VariableDef.Local, VariableDef.MethodParameter, VariableDef.StaticField, VariableDef.This

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

    • asCondition

      default ExpressionDef 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
    • isNonNull

      default ExpressionDef isNonNull()
      Returns:
      Is non-null expression
      Since:
      1.2
    • isNull

      default ExpressionDef isNull()
      Returns:
      Is null expression
      Since:
      1.2
    • 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
    • asConditionIf

      default StatementDef asConditionIf(StatementDef statement)
      The conditional statement based on this expression.
      Parameters:
      statement - The statement
      Returns:
      The statement returning this expression
      Since:
      1.2
    • asConditionIfElse

      default StatementDef asConditionIfElse(StatementDef statement, StatementDef elseStatement)
      The conditional statement based on this expression.
      Parameters:
      statement - The statement
      elseStatement - The else statement
      Returns:
      The statement returning this expression
      Since:
      1.2
    • asConditionIfElse

      default ExpressionDef asConditionIfElse(ExpressionDef expression, ExpressionDef elseExpression)
      The conditional if else expression.
      Parameters:
      expression - The expression
      elseExpression - The else expression
      Returns:
      The statement returning this expression
      Since:
      1.2
    • 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
    • asExpressionSwitch

      default ExpressionDef.Switch asExpressionSwitch(TypeDef type, Map<ExpressionDef.Constant,ExpressionDef> cases)
      Turn this expression into an expression switch.
      Parameters:
      type - The expression type
      cases - 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 type
      cases - The cases
      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
    • convert

      default ExpressionDef convert(TypeDef typeDef)
      Convert this variable to a different type.
      Parameters:
      typeDef - The type
      Returns:
      the convert 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
    • invoke

      default ExpressionDef.CallInstanceMethod invoke(MethodDef methodDef)
      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 name
      parameters - The parameters
      returning - The returning
      Returns:
      The call to the instance method
      Since:
      1.2
    • invoke

      default ExpressionDef.CallInstanceMethod invoke(String name, TypeDef returning, List<ExpressionDef> parameters)
      The call the instance method expression.
      Parameters:
      name - The method name
      parameters - The parameters
      returning - 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 element
      parameters - 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 element
      parameters - The parameters
      Returns:
      The call to the instance method
      Since:
      1.2
    • 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)
      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

      static ExpressionDef.NewInstance instantiate(ClassTypeDef type)
      The new instance expression.
      Parameters:
      type - The type
      Returns:
      The new instance
    • instantiate

      static ExpressionDef.NewInstance instantiate(ClassTypeDef type, List<ExpressionDef> values)
      The new instance expression.
      Parameters:
      type - The type
      values - 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 instance
      name - The method name
      parameters - The parameters
      returning - 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 def
      name - The method name
      parameters - The parameters
      returning - The returning
      Returns:
      The call to the static method