Class TypeConversion
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.types.TypeConversion
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JTypeMirrorbinaryNumericPromotion(JTypeMirror t, JTypeMirror s)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)static JClassTypecapture(JClassType type)Perform capture conversion on the type t.static JTypeMirrorcapture(JTypeMirror t)Perform capture conversion on the type t.static booleanisConvertibleInCastContext(JTypeMirror t, JTypeMirror s)Is t convertible to s by boxing/unboxing conversion? Only t can undergo conversion.static booleanisConvertibleUsingBoxing(JTypeMirror t, JTypeMirror s)Is t convertible to s by boxing/unboxing/widening conversion? Only t can undergo conversion.static booleanisWilcardParameterized(JTypeMirror t)Returns true if the type is a parameterized class type, which has wildcards as type arguments.static JTypeMirrorunaryNumericPromotion(JTypeMirror t)Performs Unary numeric promotion (JLS§5.6.1).
-
-
-
Method Detail
-
unaryNumericPromotion
public static JTypeMirror unaryNumericPromotion(JTypeMirror t)
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
public static JTypeMirror binaryNumericPromotion(JTypeMirror t, JTypeMirror s)
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
public static boolean isConvertibleUsingBoxing(JTypeMirror t, JTypeMirror s)
Is t convertible to s by boxing/unboxing/widening conversion? Only t can undergo conversion.
-
isConvertibleInCastContext
public static boolean isConvertibleInCastContext(JTypeMirror t, JTypeMirror s)
Is t convertible to s by boxing/unboxing conversion? Only t can undergo conversion.
-
capture
public static JTypeMirror capture(JTypeMirror t)
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
public static JClassType capture(JClassType type)
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
public static boolean isWilcardParameterized(JTypeMirror t)
Returns true if the type is a parameterized class type, which has wildcards as type arguments. Capture variables don't count.
-
-