@Override
    public T newInstance(Object... args) {
        if (args[0] != null) {
            if (args[0] instanceof String || args[0] instanceof Character) {
                @SuppressWarnings("unchecked") //The expression type is an enum
                T rv = (T) Enum.valueOf(getType().asSubclass(Enum.class), (String) args[0].toString());
                return rv;
            } else if (args[0] instanceof Number) {
                return values[((Number) args[0]).intValue()];
            } else {
                @SuppressWarnings("unchecked")
                T rv = (T) args[0];
                return rv;
            }
        } else {
            return null;
        }
    }
{@code EnumConversion} ensures that the results of an enum projection conform to the type of the
projection expression

@author tiwe

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