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

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
    • asConditionAnd

      default ExpressionDef asConditionAnd(ExpressionDef expression)
      The and condition of this variable.
      Parameters:
      expression - The expression of this variable
      Returns:
      The "and" condition expression
      Since:
      1.3
    • asConditionOr

      default ExpressionDef asConditionOr(ExpressionDef expression)
      The or condition of this variable.
      Parameters:
      expression - The expression of this variable
      Returns:
      The "or" condition expression
      Since:
      1.3
    • 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
    • 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
    • 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<? extends 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
    • 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)
      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