in stetho/src/main/java/com/facebook/stetho/inspector/domstorage/SharedPreferencesHelper.java [80:108]
public static Object valueFromString(String newValue, Object existingValue)
throws IllegalArgumentException {
if (existingValue instanceof Integer) {
return Integer.parseInt(newValue);
} else if (existingValue instanceof Long) {
return Long.parseLong(newValue);
} else if (existingValue instanceof Float) {
return Float.parseFloat(newValue);
} else if (existingValue instanceof Boolean) {
return parseBoolean(newValue);
} else if (existingValue instanceof String) {
return newValue;
} else if (existingValue instanceof Set) {
try {
JSONArray obj = new JSONArray(newValue);
int objN = obj.length();
HashSet<String> set = new HashSet<String>(objN);
for (int i = 0; i < objN; i++) {
set.add(obj.getString(i));
}
return set;
} catch (JSONException e) {
throw new IllegalArgumentException(e);
}
} else {
throw new IllegalArgumentException(
"Unsupported type: " + existingValue.getClass().getName());
}
}