private static TypeReference unbox(final TypeReference t) { return t != null ? MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(t) : null; }
public static boolean isPrimitiveOrWrapper(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).isPrimitive(); }
public static boolean isBoolean(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType() == JvmType.Boolean; }
public static boolean isBoolean(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType() == JvmType.Boolean; }
public static boolean isBoolean(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType() == JvmType.Boolean; }
public static boolean isPrimitiveOrWrapper(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).isPrimitive(); }
public static boolean isPrimitiveOrWrapper(@Nullable final TypeReference type) { if (type == null) { return false; } return MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).isPrimitive(); }
private static int getTypeRank(@NotNull final TypeReference type) { final TypeReference unboxedType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type); final Integer rank = TYPE_TO_RANK_MAP.get(unboxedType.getSimpleType()); if (rank != null) { return rank; } if (StringUtilities.equals(type.getInternalName(), STRING_DESCRIPTOR)) { return STRING_RANK; } return Integer.MAX_VALUE; }
public static boolean isArithmetic(@Nullable final TypeReference type) { if (type == null) { return false; } final JvmType jvmType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType(); return jvmType.isNumeric() && jvmType != JvmType.Boolean; }
public static boolean isArithmetic(@Nullable final TypeReference type) { if (type == null) { return false; } final JvmType jvmType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType(); return jvmType.isNumeric() && jvmType != JvmType.Boolean; }
private static int getTypeRank(@NotNull final TypeReference type) { final TypeReference unboxedType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type); final Integer rank = TYPE_TO_RANK_MAP.get(unboxedType.getSimpleType()); if (rank != null) { return rank; } if (StringUtilities.equals(type.getInternalName(), STRING_DESCRIPTOR)) { return STRING_RANK; } return Integer.MAX_VALUE; }
private static int getTypeRank(@NotNull final TypeReference type) { final TypeReference unboxedType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type); final Integer rank = TYPE_TO_RANK_MAP.get(unboxedType.getSimpleType()); if (rank != null) { return rank; } if (StringUtilities.equals(type.getInternalName(), STRING_DESCRIPTOR)) { return STRING_RANK; } return Integer.MAX_VALUE; }
public static boolean isArithmetic(@Nullable final TypeReference type) { if (type == null) { return false; } final JvmType jvmType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type).getSimpleType(); return jvmType.isNumeric() && jvmType != JvmType.Boolean; }
private TypeReference doBinaryPromotionStrict(final ResolveResult left, final ResolveResult right) { if (left == null || right == null) { return null; } TypeReference leftType = left.getType(); TypeReference rightType = right.getType(); if (leftType == null || rightType == null) { return null; } leftType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(leftType); rightType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(rightType); if (StringUtilities.equals(leftType.getInternalName(), "java/lang/String")) { return leftType; } if (StringUtilities.equals(rightType.getInternalName(), "java/lang/String")) { return rightType; } return MetadataHelper.findCommonSuperType(leftType, rightType); }
private TypeReference doBinaryPromotionStrict(final ResolveResult left, final ResolveResult right) { if (left == null || right == null) { return null; } TypeReference leftType = left.getType(); TypeReference rightType = right.getType(); if (leftType == null || rightType == null) { return null; } leftType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(leftType); rightType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(rightType); if (StringUtilities.equals(leftType.getInternalName(), "java/lang/String")) { return leftType; } if (StringUtilities.equals(rightType.getInternalName(), "java/lang/String")) { return rightType; } return MetadataHelper.findCommonSuperType(leftType, rightType); }
private TypeReference doBinaryPromotionStrict(final ResolveResult left, final ResolveResult right) { if (left == null || right == null) { return null; } TypeReference leftType = left.getType(); TypeReference rightType = right.getType(); if (leftType == null || rightType == null) { return null; } leftType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(leftType); rightType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(rightType); if (StringUtilities.equals(leftType.getInternalName(), "java/lang/String")) { return leftType; } if (StringUtilities.equals(rightType.getInternalName(), "java/lang/String")) { return rightType; } return MetadataHelper.findCommonSuperType(leftType, rightType); }
@Override public Expression apply(final AstNode input) { return new BinaryOperatorExpression( node, BinaryOperatorType.INEQUALITY, new PrimitiveExpression( Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast( MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type) .getSimpleType(), 0 ) ) ); } }
@Override public Expression apply(final AstNode input) { return new BinaryOperatorExpression( node, BinaryOperatorType.INEQUALITY, new PrimitiveExpression( Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast( MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type) .getSimpleType(), 0 ) ) ); } }
@Override public Expression apply(final AstNode input) { return new BinaryOperatorExpression( node, BinaryOperatorType.INEQUALITY, new PrimitiveExpression( Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast( MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(type) .getSimpleType(), 0 ) ) ); } }
@Override public Void visitUnaryOperatorExpression(final UnaryOperatorExpression node, final Void data) { super.visitUnaryOperatorExpression(node, data); switch (node.getOperator()) { case NOT: { final Expression operand = node.getExpression(); final ResolveResult result = _resolver.apply(operand); if (result != null && result.getType() != null && !TypeUtilities.isBoolean(result.getType()) && MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(result.getType()).getSimpleType().isNumeric()) { final TypeReference comparandType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(result.getType()); operand.replaceWith( new Function<AstNode, AstNode>() { @Override public AstNode apply(final AstNode input) { return new BinaryOperatorExpression( operand, BinaryOperatorType.INEQUALITY, new PrimitiveExpression(Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast(comparandType.getSimpleType(), 0)) ); } } ); } break; } } return null; }