Enum 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>
- Enclosing class:
- ExprContext
public static enum ExprContext.ExprContextKind extends Enum<ExprContext.ExprContextKind>
Kind of context.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ASSIGNMENT
Assignment context.BOOLEAN
Boolean contexts, which unbox their operand to a boolean.CAST
Cast context.INVOCATION
Invocation context (method arguments).MISSING
Kind for a missing context (RegularCtx.NO_CTX
).NUMERIC
Numeric context.STRING
String contexts, which convert the operand to a string usingString.valueOf(Object)
, or the equivalent for a primitive type.TERNARY
Kind for a standalone ternary (both branches are then in this context).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExprContext.ExprContextKind
valueOf(String name)
Returns the enum constant of this type with the specified name.static ExprContext.ExprContextKind[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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
- 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 usingString.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 anif
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 nameNullPointerException
- if the argument is null
-
-