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
Kind of context.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAssignment context.Boolean contexts, which unbox their operand to a boolean.Cast context.Invocation context (method arguments).Kind for a missing context (RegularCtx.NO_CTX).Numeric context.String contexts, which convert the operand to a string usingString.valueOf(Object), or the equivalent for a primitive type.Kind for a standalone ternary (both branches are then in this context). -
Method Summary
Modifier and TypeMethodDescriptionstatic ExprContext.ExprContextKindReturns the enum constant of this class with the specified name.static ExprContext.ExprContextKind[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INVOCATION
Invocation context (method arguments). -
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
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
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
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
Kind for a standalone ternary (both branches are then in this context). -
MISSING
Kind for a missing context (RegularCtx.NO_CTX). -
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 anifstatement, an assert statement, etc.This provides a target type for conversions, but not for poly expressions.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-