Enum ExprContext.ExprContextKind

    • Enum Constant Detail

      • ASSIGNMENT

        public static final ExprContext.ExprContextKind ASSIGNMENT
        Assignment context. This includes:
        • RHS of an assignment
        • Return statement
        • 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).
      • 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 Detail

      • values

        public static ExprContext.ExprContextKind[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ExprContext.ExprContextKind c : ExprContext.ExprContextKind.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ExprContext.ExprContextKind valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
        NullPointerException - if the argument is null