@Override
    @SuppressWarnings("unchecked")
    public T newInstance(Object... args) {
        for (int i = 0; i < args.length; i++) {
            Class<?> type = expr.getArgs().get(i).getType();
            if (Enum.class.isAssignableFrom(type) && !type.isInstance(args[i])) {
                if (args[i] instanceof String) {
                    args[i] = Enum.valueOf((Class) type, (String) args[i]);
                } else if (args[i] instanceof Number) {
                    args[i] = getValues((Class) type)[((Number) args[i]).intValue()];
                }
            } else if (args[i] instanceof Number && !type.isInstance(args[i])) {
                if (type.equals(Boolean.class)) {
                    args[i] = ((Number) args[i]).intValue() > 0;
                } else if (Number.class.isAssignableFrom(type)) {
                    args[i] = MathUtils.cast((Number) args[i], (Class) type);
                }
            }
        }
        return expr.newInstance(args);
    }
{@code NumberConversions} ensures that the results of a projection involving numeric expressions
conform to the types of the numeric expressions

@author tiwe

@param <T>
querydsl-core/src/main/java/com/querydsl/core/support/NumberConversions.java