@Override public RelWriter explainTerms(final RelWriter pw) { return super.explainTerms(pw).item("fields", Primitive.asList(fields)); }
if (Primitive.isBox(type)) { type = Primitive.ofBox(type).primitiveClass; return writer; final Primitive primitive = Primitive.of(type); final BigDecimal bigDecimal; if (primitive != null) { final Primitive primitive2 = Primitive.ofBox(type); if (primitive2 != null) { writer.append(primitive2.boxClass.getSimpleName() + ".valueOf("); list(writer, Primitive.asList(value), "[] {\n", ",\n", "}"); return writer;
/** * Converts a primitive class to a boxed class; returns other classes * unchanged. */ public static Class box(Class type) { Primitive primitive = of(type); return primitive == null ? type : primitive.boxClass; }
private static Object convert(Object o, Class clazz) { if (o == null) { return null; } Primitive primitive = Primitive.of(clazz); if (primitive != null) { clazz = primitive.boxClass; } else { primitive = Primitive.ofBox(clazz); } if (clazz.isInstance(o)) { return o; } if (o instanceof Date && primitive != null) { o = ((Date) o).getTime() / DateTimeUtils.MILLIS_PER_DAY; } if (o instanceof Number && primitive != null) { return primitive.number((Number) o); } return o; } }
/** Converts from internal representation to JDBC representation used by * arguments of user-defined functions. For example, converts date values from * {@code int} to {@link java.sql.Date}. */ static Expression fromInternal(Expression e, Class<?> targetType) { if (e == ConstantUntypedNull.INSTANCE) { return e; } if (!(e.getType() instanceof Class)) { return e; } if (targetType.isAssignableFrom((Class) e.getType())) { return e; } if (targetType == java.sql.Date.class) { return Expressions.call(BuiltInMethod.INTERNAL_TO_DATE.method, e); } if (targetType == java.sql.Time.class) { return Expressions.call(BuiltInMethod.INTERNAL_TO_TIME.method, e); } if (targetType == java.sql.Timestamp.class) { return Expressions.call(BuiltInMethod.INTERNAL_TO_TIMESTAMP.method, e); } if (Primitive.is(e.type) && Primitive.isBox(targetType)) { // E.g. e is "int", target is "Long", generate "(long) e". return Expressions.convert_(e, Primitive.ofBox(targetType).primitiveClass); } return e; }
public static Type unbox(Type type) { Primitive primitive = Primitive.ofBox(type); if (primitive != null) { return primitive.primitiveClass; } else { return type; } }
public ArrayType(Type componentType) { this(componentType, !Primitive.is(componentType), -1L); }
/** * Returns whether a parameter is assignable from an argument by virtue * of (a) sub-classing (e.g. Writer is assignable from PrintWriter) and (b) * up-casting (e.g. int is assignable from short). * * @param parameter Parameter type * @param argument Argument type * * @return Whether parameter can be assigned from argument */ private static boolean assignableFrom(Class parameter, Class argument) { return parameter.isAssignableFrom(argument) || parameter.isPrimitive() && argument.isPrimitive() && Primitive.of(parameter).assignableFrom(Primitive.of(argument)); }
final Type javaRowClass = Primitive.box(this.javaRowClass); final ParameterExpression parameterV0 = Expressions.parameter(javaRowClass, "v0"); Expression arg0 = fieldReference(parameterV0, index); Expression arg1 = fieldReference(parameterV1, index); switch (Primitive.flavor(fieldClass(index))) { case OBJECT: arg0 = Types.castIfNecessary(Comparable.class, arg0);
final Type type1 = expressions.get(1).getType(); final SqlBinaryOperator op = (SqlBinaryOperator) call.getOperator(); final Primitive primitive = Primitive.ofBoxOr(type0); if (primitive == null || type1 == BigDecimal.class
Expression arg0 = fieldReference(parameterV0, index); Expression arg1 = fieldReference(parameterV1, index); switch (Primitive.flavor(fieldClass(index))) { case OBJECT: arg0 = Types.castIfNecessary(Comparable.class, arg0);