@SuppressWarnings("unchecked") @Override public <T> T get(IClientConfigKey<T> key) { Object obj = getProperty(key.key()); if (obj == null) { return null; } Class<T> type = key.type(); if (type.isInstance(obj)) { return type.cast(obj); } else { if (obj instanceof String) { String stringValue = (String) obj; if (Integer.class.equals(type)) { return (T) Integer.valueOf(stringValue); } else if (Boolean.class.equals(type)) { return (T) Boolean.valueOf(stringValue); } else if (Float.class.equals(type)) { return (T) Float.valueOf(stringValue); } else if (Long.class.equals(type)) { return (T) Long.valueOf(stringValue); } else if (Double.class.equals(type)) { return (T) Double.valueOf(stringValue); } else if (TimeUnit.class.equals(type)) { return (T) TimeUnit.valueOf(stringValue); } throw new IllegalArgumentException( "Unable to convert string value to desired type " + type); } throw new IllegalArgumentException("Unable to convert value to desired type " + type); } }