private Object parseAll(Object value, ELContext context) { if (value instanceof String) { return new DynamicConfigProperty((String) value, expressions, context); } else if (value instanceof Map<?, ?>) { Map<?, ?> mapValue = (Map<?, ?>) value; Map<Object, Object> newMap = Maps.newHashMap(); for (Map.Entry<?, ?> entry : mapValue.entrySet()) { newMap.put(entry.getKey(), parseAll(entry.getValue(), context)); } return Collections.unmodifiableMap(newMap); } else if (value instanceof List<?>) { List<Object> newList = Lists.newArrayList(); for (Object entry : (List<?>) value) { newList.add(parseAll(entry, context)); } return Collections.unmodifiableList(newList); } else { return value; } }
private Object parseAll(Object value, ELContext context) { if (value instanceof String) { return new DynamicConfigProperty((String) value, expressions, context); } else if (value instanceof Map<?, ?>) { Map<?, ?> mapValue = (Map<?, ?>) value; Map<Object, Object> newMap = Maps.newHashMap(); for (Map.Entry<?, ?> entry : mapValue.entrySet()) { newMap.put(entry.getKey(), parseAll(entry.getValue(), context)); } return Collections.unmodifiableMap(newMap); } else if (value instanceof List<?>) { List<Object> newList = Lists.newArrayList(); for (Object entry : (List<?>) value) { newList.add(parseAll(entry, context)); } return Collections.unmodifiableList(newList); } else { return value; } }
private Object parseAll(Object value, ELContext context) { if (value instanceof String) { return new DynamicConfigProperty((String) value, expressions, context); } else if (value instanceof Map<?, ?>) { Map<?, ?> mapValue = (Map<?, ?>) value; Map<Object, Object> newMap = Maps.newHashMap(); for (Map.Entry<?, ?> entry : mapValue.entrySet()) { newMap.put(entry.getKey(), parseAll(entry.getValue(), context)); } return Collections.unmodifiableMap(newMap); } else if (value instanceof List<?>) { List<Object> newList = Lists.newArrayList(); for (Object entry : (List<?>) value) { newList.add(parseAll(entry, context)); } return Collections.unmodifiableList(newList); } else { return value; } }
/** * Convert a JSON value to a configuration value. */ private static Object jsonToConfig(Object json, Expressions expressions, ELContext context) { if (JSONObject.NULL.equals(json)) { return null; } else if (json instanceof CharSequence) { return new DynamicConfigProperty(json.toString(), expressions, context); } else if (json instanceof JSONArray) { JSONArray jsonArray = (JSONArray) json; List<Object> values = new ArrayList<Object>(jsonArray.length()); for (int i = 0, j = jsonArray.length(); i < j; ++i) { values.add(jsonToConfig(jsonArray.opt(i), expressions, context)); } return Collections.unmodifiableList(values); } else if (json instanceof JSONObject) { return jsonToMap((JSONObject) json, expressions, context); } // A (boxed) primitive. return json; }
/** * Convert a JSON value to a configuration value. */ private static Object jsonToConfig(Object json, Expressions expressions, ELContext context) { if (JSONObject.NULL.equals(json)) { return null; } else if (json instanceof CharSequence) { return new DynamicConfigProperty(json.toString(), expressions, context); } else if (json instanceof JSONArray) { JSONArray jsonArray = (JSONArray) json; List<Object> values = new ArrayList<Object>(jsonArray.length()); for (int i = 0, j = jsonArray.length(); i < j; ++i) { values.add(jsonToConfig(jsonArray.opt(i), expressions, context)); } return Collections.unmodifiableList(values); } else if (json instanceof JSONObject) { return jsonToMap((JSONObject) json, expressions, context); } // A (boxed) primitive. return json; }