/** * Recursively merge values from parent objects in the prototype chain. * * @return The object merged with all parents. * * @throws ContainerConfigException If there is an invalid parent parameter * in the prototype chain. */ private JSONObject mergeParents(String container, JSONObject all) throws ContainerConfigException, JSONException { JSONObject base = all.getJSONObject(container); if (DEFAULT_CONTAINER.equals(container)) { return base; } String parent = base.optString(PARENT_KEY, DEFAULT_CONTAINER); if (!all.has(parent)) { throw new ContainerConfigException( "Unable to locate parent '" + parent + "' required by " + base.getString(CONTAINER_KEY)); } return mergeObjects(mergeParents(parent, all), base); }
/** * Recursively merge values from parent objects in the prototype chain. * * @return The object merged with all parents. * * @throws ContainerConfigException If there is an invalid parent parameter * in the prototype chain. */ private JSONObject mergeParents(String container, JSONObject all) throws ContainerConfigException, JSONException { JSONObject base = all.getJSONObject(container); if (DEFAULT_CONTAINER.equals(container)) { return base; } String parent = base.optString(PARENT_KEY, DEFAULT_CONTAINER); if (!all.has(parent)) { throw new ContainerConfigException( "Unable to locate parent '" + parent + "' required by " + base.getString(CONTAINER_KEY)); } return mergeObjects(mergeParents(parent, all), base); }
all.put(container, mergeParents(container, all));
all.put(container, mergeParents(container, all));