private <T> T resolveValueToType(IClientConfigKey<T> key, Object value) {
        if (value == null) {
            return null;
        }

        final Class<T> type = key.type();
        // Unfortunately there's some legacy code setting string values for typed keys.  Here are do our best to parse
        // and store the typed value
        if (!value.getClass().equals(type)) {
            try {
                if (type.equals(String.class)) {
                    return (T) value.toString();
                } else if (value.getClass().equals(String.class)) {
                    final String strValue = (String) value;
                    if (Integer.class.equals(type)) {
                        return (T) Integer.valueOf(strValue);
                    } else if (Boolean.class.equals(type)) {
                        return (T) Boolean.valueOf(strValue);
                    } else if (Float.class.equals(type)) {
                        return (T) Float.valueOf(strValue);
                    } else if (Long.class.equals(type)) {
                        return (T) Long.valueOf(strValue);
                    } else if (Double.class.equals(type)) {
                        return (T) Double.valueOf(strValue);
                    } else if (TimeUnit.class.equals(type)) {
                        return (T) TimeUnit.valueOf(strValue);
                    } else {
                        return PropertyUtils.resolveWithValueOf(type, strValue)
                                .orElseThrow(() -> new IllegalArgumentException("Unsupported value type `" + type + "'"));
                    }
                } else {
                    return PropertyUtils.resolveWithValueOf(type, value.toString())
                            .orElseThrow(() -> new IllegalArgumentException("Incompatible value type `" + value.getClass() + "` while expecting '" + type + "`"));
                }
            } catch (Exception e) {
                throw new IllegalArgumentException("Error parsing value '" + value + "' for '" + key.key() + "'", e);
            }
        } else {
            return (T)value;
        }
    }
Resolve a property's final value from the property value.
- client scope
- default scope
ribbon-core/src/main/java/com/netflix/client/config/ReloadableClientConfig.java