private Object getExpectedType(Class<?> type) {
        Object object = get(null, null);
        if (object == null || type.isAssignableFrom(object.getClass())) {
            return object;
        } else {
            throw new ConversionException("Expected a " + type.getName() + " but value is a "
                    + object.getClass().getName());
        }
    }