Enum Class ExprContext.ExprContextKind

java.lang.Object
java.lang.Enum<ExprContext.ExprContextKind>
net.sourceforge.pmd.lang.java.types.ast.ExprContext.ExprContextKind
All Implemented Interfaces:
Serializable, Comparable<ExprContext.ExprContextKind>, Constable
Enclosing class:
ExprContext

public static enum ExprContext.ExprContextKind extends Enum<ExprContext.ExprContextKind>
Kind of context.
  • Enum Constant Details

    • INVOCATION

      public static final ExprContext.ExprContextKind INVOCATION
      Invocation context (method arguments).
    • ASSIGNMENT

      public static final ExprContext.ExprContextKind ASSIGNMENT
      Assignment context. This includes:
      • RHS of an assignment
      • Return statement or return expression of a lambda
      • Array initializer
      • Superclass constructor invocation

      An assignment context flows through ternary/switch branches. They are a context for poly expressions.

    • CAST

      public static final ExprContext.ExprContextKind CAST
      Cast context. Lambdas and method refs can use them as a target type, but no other expressions. Cast contexts do not flow through ternary/switch branches.
    • NUMERIC

      public static final ExprContext.ExprContextKind NUMERIC
      Numeric context. May determine that an (un)boxing or primitive widening conversion occurs. These is the context for operands of arithmetic expressions, array indices.

      For instance:

      
       Integer integer;
      
       array[integer] // Integer is unboxed to int
       integer + 1    // Integer is unboxed to int
       0 + 1.0        // int (left) is widened to double
       integer + 1.0  // Integer is unboxed to int, then widened to double
       
    • STRING

      public static final ExprContext.ExprContextKind STRING
      String contexts, which convert the operand to a string using String.valueOf(Object), or the equivalent for a primitive type. They accept operands of any type. This is the context for the operands of a string concatenation expression, and for the message of an assert statement.
    • TERNARY

      public static final ExprContext.ExprContextKind TERNARY
      Kind for a standalone ternary (both branches are then in this context).
    • MISSING

      public static final ExprContext.ExprContextKind MISSING
      Kind for a missing context (RegularCtx.NO_CTX).
    • BOOLEAN

      public static final ExprContext.ExprContextKind BOOLEAN
      Boolean contexts, which unbox their operand to a boolean. They accept operands of type boolean or Boolean. This is the context for e.g. the condition of an if statement, an assert statement, etc.

      This provides a target type for conversions, but not for poly expressions.

  • Method Details

    • values

      public static ExprContext.ExprContextKind[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ExprContext.ExprContextKind valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null