/** * Method to recursively convert a Json tree, consisting of {@link JsonElement}s, to a to a * configuration tree, consisting of {@link ConfigurationElement}s * * @param parentConfiguration {@link ConfigurationElement} The parent configuration of the new * configurations added in this method call * @param parentJsonElement {@link JsonElement} The parent of the {@link JsonElement}s which will * be converted to {@link ConfigurationElement}s */ private void recConvertJsonTreeToConfigurationTree( ConfigurationElement parentConfiguration, JsonElement parentJsonElement) { if (parentJsonElement.isJsonObject()) { Set<Map.Entry<String, JsonElement>> childConfigurations = ((JsonObject) parentJsonElement).entrySet(); for (Map.Entry<String, JsonElement> childConfiguration : childConfigurations) { if (childConfiguration.getValue().isJsonObject()) { ConfigurationElement newConfigurationSection = new ConfigurationElement(childConfiguration.getKey()); parentConfiguration.addChildConfiguration(newConfigurationSection); recConvertJsonTreeToConfigurationTree( newConfigurationSection, childConfiguration.getValue()); } else { parentConfiguration.addChildConfiguration( new ConfigurationElement( childConfiguration.getKey(), new JsonConfigurationValue(childConfiguration.getValue()))); } } } }