/** * Method to recursively convert a configuration tree, consisting of {@link * ConfigurationElement}s, to a to a Json tree, consisting of {@link JsonElement}s * * @param parentJsonObject {@link JsonObject} The parent of the new {@link JsonElement}s added in * this method call * @param parentConfigurationElement {@link ConfigurationElement} The parent of the * configurations, which will be converted to {@link JsonElement}s */ private void recConvertConfigurationTreeToJsonTree( JsonObject parentJsonObject, ConfigurationElement parentConfigurationElement) { for (ConfigurationElement configurationElement : parentConfigurationElement.getChildren()) { if (configurationElement.isConfigurationSection()) { JsonElement newJsonElement = new JsonObject(); parentJsonObject.add(configurationElement.getName(), newJsonElement); recConvertConfigurationTreeToJsonTree((JsonObject) newJsonElement, configurationElement); } else if (configurationElement.isConfigurationObject()) { if (configurationElement.getValue() instanceof JsonConfigurationValue) { JsonElement newJsonElement = ((JsonConfigurationValue) configurationElement.getValue()).getJsonElement(); parentJsonObject.add(configurationElement.getName(), newJsonElement); } } } }