@Override public IValue withType( IType type, ITypeContext typeContext, MarkerList markers, IContext context) { if (type == Types.BOOLEAN) { return this; } return type.isSuperTypeOf(Types.BOOLEAN) ? new BoxedValue(this, Types.BOOLEAN.boxMethod) : null; }
@Override public int getTypeMatch(IType type) { if (this.field == null) { return 0; } IType type1 = this.getType(); if (type.equals(type1)) { return 3; } if (type.isSuperTypeOf(type1)) { return 2; } return 0; }
public static IValue autoBox(IValue value, IType valueType, IType targetType) { if (!targetType.isSuperTypeOf(valueType)) { return null; } boolean primitive = valueType.isPrimitive(); if (primitive != targetType.isPrimitive()) { // Box Primitive -> Object if (primitive) { return new BoxedValue(value, valueType.getBoxMethod()); } // Unbox Object -> Primitive return new BoxedValue(value, targetType.getUnboxMethod()); } return value; }
@Override public boolean isType(IType type) { return type == Types.BOOLEAN || type.isSuperTypeOf(Types.BOOLEAN); }
@Override public boolean isType(IType type) { return this.field == null ? false : type.isSuperTypeOf(this.getType()); }