public static boolean isAssignable(Class to, Class from) { return (to.isPrimitive() ? boxPrimitive(to) : to).isAssignableFrom(from.isPrimitive() ? boxPrimitive(from) : from); } }
public static boolean isNumericallyCoercible(Class target, Class parm) { Class boxedTarget = target.isPrimitive() ? boxPrimitive(target) : target; if (boxedTarget != null && Number.class.isAssignableFrom(target)) { if ((boxedTarget = parm.isPrimitive() ? boxPrimitive(parm) : parm) != null) { return Number.class.isAssignableFrom(boxedTarget); } } return false; }
public static boolean isAssignable(Class to, Class from) { return (to.isPrimitive() ? boxPrimitive(to) : to).isAssignableFrom(from.isPrimitive() ? boxPrimitive(from) : from); }
public static boolean isNumericallyCoercible(Class target, Class parm) { Class boxedTarget = target.isPrimitive() ? boxPrimitive(target) : target; if (boxedTarget != null && Number.class.isAssignableFrom(target)) { if ((boxedTarget = parm.isPrimitive() ? boxPrimitive(parm) : parm) != null) { return Number.class.isAssignableFrom(boxedTarget); } } return false; }
public static boolean isNumericallyCoercible(Class target, Class parm) { Class boxedTarget = target.isPrimitive() ? boxPrimitive(target) : target; if (boxedTarget != null && Number.class.isAssignableFrom(target)) { if ((boxedTarget = parm.isPrimitive() ? boxPrimitive(parm) : parm) != null) { return Number.class.isAssignableFrom(boxedTarget); } } return false; }
public static String getTypeDescriptor(Class<?> type) { if (Number.class.isAssignableFrom(ParseTools.boxPrimitive(type))) { return "numeric"; } else { return type.getCanonicalName(); } } }
private boolean areCompatible(Class<?> leftClass, Class<?> rightClass) { return leftClass.equals(NullType.class) || rightClass.equals(NullType.class) || ( Number.class.isAssignableFrom(rightClass) && Number.class.isAssignableFrom(leftClass) ) || ( (rightClass.isPrimitive() || leftClass.isPrimitive()) && canConvert(boxPrimitive(leftClass), boxPrimitive(rightClass)) ); }
private boolean areCompatible(Class<?> leftClass, Class<?> rightClass) { return leftClass.equals(NullType.class) || rightClass.equals(NullType.class) || ( Number.class.isAssignableFrom(rightClass) && Number.class.isAssignableFrom(leftClass) ) || ( (rightClass.isPrimitive() || leftClass.isPrimitive()) && canConvert(boxPrimitive(leftClass), boxPrimitive(rightClass)) ); }
/** * Return the Boxed type of this Option, e.g: If the option is actual an <code>int.class</code>, return * <code>Integer.class</code> instead. */ @Override public Class<?> getBoxedType() { return ParseTools.boxPrimitive(getType()); }
public static void expectType(ParserContext pCtx, Accessor expression, Class type, boolean compileMode) { Class retType = expression.getKnownEgressType(); if (compileMode) { if ((retType == null || !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) && (!Object.class.equals(retType) || pCtx.isStrictTypeEnforcement())) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } } else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } }
public static void expectType(ParserContext pCtx, Accessor expression, Class type, boolean compileMode) { Class retType = expression.getKnownEgressType(); if (compileMode) { if ((retType == null || !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) && (!Object.class.equals(retType) || pCtx.isStrictTypeEnforcement())) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } } else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } }
public static void expectType(ParserContext pCtx, ASTNode node, Class type, boolean compileMode) { Class retType = boxPrimitive(node.getEgressType()); if (compileMode) { if ((retType == null || !boxPrimitive(type).isAssignableFrom(retType)) && (!Object.class.equals(retType) && pCtx.isStrictTypeEnforcement())) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } } else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(retType)) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } }
public static void expectType(ParserContext pCtx, ASTNode node, Class type, boolean compileMode) { Class retType = boxPrimitive(node.getEgressType()); if (compileMode) { if ((retType == null || !boxPrimitive(type).isAssignableFrom(retType)) && (!Object.class.equals(retType) && pCtx.isStrictTypeEnforcement())) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } } else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(retType)) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0); } }
public static void expectType(Accessor expression, Class type, boolean compileMode) { Class retType = expression.getKnownEgressType(); if (compileMode) { if ((retType == null || !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) && (!Object.class.equals(retType) || getCurrentThreadParserContext().isStrictTypeEnforcement())) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "null")); } } else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) { throw new CompileException("was expecting type: " + type.getName() + "; but found type: " + (retType != null ? retType.getName() : "null")); } }
private void initSigner(Class type) { if (Integer.class.isAssignableFrom(type = boxPrimitive(type))) signer = new IntegerSigner(); else if (Double.class.isAssignableFrom(type)) signer = new DoubleSigner(); else if (Long.class.isAssignableFrom(type)) signer = new LongSigner(); else if (Float.class.isAssignableFrom(type)) signer = new FloatSigner(); else if (Short.class.isAssignableFrom(type)) signer = new ShortSigner(); else if (BigInteger.class.isAssignableFrom(type)) signer = new BigIntSigner(); else if (BigDecimal.class.isAssignableFrom(type)) signer = new BigDecSigner(); else { throw new CompileException("illegal use of '-': cannot be applied to: " + type.getName(), expr, start); } }
private void initSigner(Class type) { if (Integer.class.isAssignableFrom(type = boxPrimitive(type))) signer = new IntegerSigner(); else if (Double.class.isAssignableFrom(type)) signer = new DoubleSigner(); else if (Long.class.isAssignableFrom(type)) signer = new LongSigner(); else if (Float.class.isAssignableFrom(type)) signer = new FloatSigner(); else if (Short.class.isAssignableFrom(type)) signer = new ShortSigner(); else if (BigInteger.class.isAssignableFrom(type)) signer = new BigIntSigner(); else if (BigDecimal.class.isAssignableFrom(type)) signer = new BigDecSigner(); else { throw new CompileException("illegal use of '-': cannot be applied to: " + type.getName(), expr, start); } }
private void initSigner(Class type) { if (Integer.class.isAssignableFrom(type = boxPrimitive(type))) signer = new IntegerSigner(); else if (Double.class.isAssignableFrom(type)) signer = new DoubleSigner(); else if (Long.class.isAssignableFrom(type)) signer = new LongSigner(); else if (Float.class.isAssignableFrom(type)) signer = new FloatSigner(); else if (Short.class.isAssignableFrom(type)) signer = new ShortSigner(); else if (BigInteger.class.isAssignableFrom(type)) signer = new BigIntSigner(); else if (BigDecimal.class.isAssignableFrom(type)) signer = new BigDecSigner(); else { throw new CompileException("illegal use of '-': cannot be applied to: " + type.getName()); } }
public Negation(char[] expr, int start, int offset, int fields, ParserContext pCtx) { super(pCtx); this.expr = expr; this.start = start; this.offset = offset; if ((fields & COMPILE_IMMEDIATE) != 0) { if (((this.stmt = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)).getKnownEgressType() != null) && (!ParseTools.boxPrimitive(stmt.getKnownEgressType()).isAssignableFrom(Boolean.class))) { throw new CompileException("negation operator cannot be applied to non-boolean type", expr, start); } } }
public Negation(char[] name, int fields, ParserContext pCtx) { this.name = name; if ((fields & COMPILE_IMMEDIATE) != 0) { if (((this.stmt = (ExecutableStatement) subCompileExpression(name, pCtx)).getKnownEgressType() != null) && (!ParseTools.boxPrimitive(stmt.getKnownEgressType()).isAssignableFrom(Boolean.class))) { throw new CompileException("negation operator cannot be applied to non-boolean type"); } } }
public Negation(char[] expr, int start, int offset, int fields, ParserContext pCtx) { super(pCtx); this.expr = expr; this.start = start; this.offset = offset; if ((fields & COMPILE_IMMEDIATE) != 0) { if (((this.stmt = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)).getKnownEgressType() != null) && (!ParseTools.boxPrimitive(stmt.getKnownEgressType()).isAssignableFrom(Boolean.class))) { throw new CompileException("negation operator cannot be applied to non-boolean type", expr, start); } } }