/** * Initialize each container's configuration. */ private Map<String, Map<String, Object>> createContainers(JSONObject json) { Map<String, Map<String, Object>> map = Maps.newHashMap(); for (String container : JSONObject.getNames(json)) { ELContext context = createExpressionContext(container); map.put(container, jsonToMap(json.optJSONObject(container), expressions, context)); } return map; }
/** * Initialize each container's configuration. */ private Map<String, Map<String, Object>> createContainers(JSONObject json) { Map<String, Map<String, Object>> map = Maps.newHashMap(); for (String container : JSONObject.getNames(json)) { ELContext context = createExpressionContext(container); map.put(container, jsonToMap(json.optJSONObject(container), expressions, context)); } return map; }
/** * 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; }