@SuppressWarnings("unchecked")
    private List<? extends Expression<?>> normalizeNumericArgs(List<? extends Expression<?>> args) {
        //we do not yet let it produce these types
        //we verify the types with isAssignableFrom()
        @SuppressWarnings("unchecked")
        List<? extends Expression<? extends Number>> potentialArgs =
                (List<? extends Expression<? extends Number>>) args;
        boolean hasConstants = false;
        Class<? extends Number> numType = null;
        for (Expression<? extends Number> arg : potentialArgs) {
            if (Number.class.isAssignableFrom(arg.getType())) {
                if (arg instanceof Constant<?>) {
                    hasConstants = true;
                } else {
                    numType = arg.getType();
                }
            }
        }
        if (hasConstants && numType != null) {
            //now we do let the potentialArgs help us
            final List<Expression<?>> newArgs = new ArrayList<Expression<?>>(args.size());
            for (final Expression<? extends Number> arg : potentialArgs) {
                if (arg instanceof Constant<?> && Number.class.isAssignableFrom(arg.getType())
                        && !arg.getType().equals(numType)) {
                    final Number number = ((Constant<? extends Number>) arg).getConstant();
                    newArgs.add(ConstantImpl.create(MathUtils.cast(number, numType)));
                } else {
                    newArgs.add(arg);
                }
            }
            return newArgs;
        } else {
            //the types are all non-constants, or not Number expressions
            return potentialArgs;
        }
    }
{@code JPQLSerializer} serializes Querydsl expressions into JPQL syntax.

@author tiwe
querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java