Class TypeConversion
java.lang.Object
net.sourceforge.pmd.lang.java.types.TypeConversion
Utility class for type conversions, as defined in JLS§5.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JTypeMirrorJLS§5.6.2 https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html#jls-5.6.2 Binary numeric promotion is performed on the operands of certain operators: The multiplicative operators *, /, and % (§15.17) The addition and subtraction operators for numeric types + and - (§15.18.2) The numerical comparison operators <, <=, >, and >= (§15.20.1) The numerical equality operators == and !static JClassTypecapture(JClassType type) Perform capture conversion on the type t.static JTypeMirrorPerform capture conversion on the type t.static booleanIs t convertible to s by boxing/unboxing conversion?static booleanIs t convertible to s by boxing/unboxing/widening conversion?static booleanReturns true if the type is a parameterized class type, which has wildcards as type arguments.static JTypeMirrorPerforms Unary numeric promotion (JLS§5.6.1).
-
Method Details
-
unaryNumericPromotion
Performs Unary numeric promotion (JLS§5.6.1).This occurs in the following situations:
- Each dimension expression in an array creation expression (§15.10.1)
- The index expression in an array access expression (§15.10.3)
- The operand of a unary plus operator + (§15.15.3)
- The operand of a unary minus operator - (§15.15.4)
- The operand of a bitwise complement operator ~ (§15.15.5)
- Each operand, separately, of a shift operator <<, >>, or >>> (§15.19).
Returns
TypeSystem.ERRORif the given type is not a numeric type,TypeSystem.UNKNOWNif the type is unresolved. -
binaryNumericPromotion
JLS§5.6.2 https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html#jls-5.6.2 Binary numeric promotion is performed on the operands of certain operators:- The multiplicative operators *, /, and % (§15.17)
- The addition and subtraction operators for numeric types + and - (§15.18.2)
- The numerical comparison operators <, <=, >, and >= (§15.20.1)
- The numerical equality operators == and != (§15.21.1)
- The integer bitwise operators &, ^, and | (§15.22.1)
- In certain cases, the conditional operator ? : (§15.25)
Returns
TypeSystem.ERRORif either of the parameters is not numeric. This DOES NOT care for unresolved types. -
isConvertibleUsingBoxing
Is t convertible to s by boxing/unboxing/widening conversion? Only t can undergo conversion. -
isConvertibleInCastContext
Is t convertible to s by boxing/unboxing conversion? Only t can undergo conversion. -
capture
Perform capture conversion on the type t. This replaces wildcards with fresh type variables. Capture conversion is not applied recursively. Capture conversion on any type other than a parameterized type (§4.5) acts as an identity conversion (§5.1.1).- Returns:
- The capture conversion of t
-
capture
Perform capture conversion on the type t. This replaces wildcards with fresh type variables. Capture conversion is not applied recursively. Capture conversion on any type other than a parameterized type (§4.5) acts as an identity conversion (§5.1.1).- Returns:
- The capture conversion of t
-
isWilcardParameterized
Returns true if the type is a parameterized class type, which has wildcards as type arguments. Capture variables don't count.
-