Skip to content

Commit

Permalink
fixed issue with missing configuration properties not cleared from co…
Browse files Browse the repository at this point in the history
…nfig file, added method for overwriting internal config object
  • Loading branch information
albogdano committed Jan 14, 2025
1 parent 58a1b21 commit 2c91e9c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions para-core/src/main/java/com/erudika/para/core/utils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,16 @@ public com.typesafe.config.Config getConfig() {
return config;
}

/**
* Overwrites the internal config object with a new one.
* @param newConfig a new Config object
* @return returns this instance for chaining
*/
public Config overwriteConfig(com.typesafe.config.Config newConfig) {
config = newConfig;
return this;
}

/**
* Constructs a sorted set of configuration keys.
* Heavily relies on the {@link Documented} annotation for sort order.
Expand Down Expand Up @@ -455,14 +465,11 @@ public String renderConfigDocumentation(String format, boolean groupByCategory)
public Map<String, Object> getConfigMap() {
Map<String, Object> configMap = new LinkedHashMap<>();
for (String keyNoPrefix : getSortedConfigKeys().keySet()) {
Object value = getConfigValue(keyNoPrefix, null);
if (value != null) {
configMap.put(getConfigRootPrefix() + "." + keyNoPrefix, value);
}
configMap.put(getConfigRootPrefix() + "." + keyNoPrefix, null);
}
for (Map.Entry<String, ConfigValue> entry : getConfig().entrySet()) {
String keyNoPrefix = entry.getKey();
String keyPrefixed = getConfigRootPrefix() + "." + entry.getKey();
String keyNoPrefix = StringUtils.removeStart(entry.getKey(), getConfigRootPrefix() + ".");
String keyPrefixed = getConfigRootPrefix() + "." + keyNoPrefix;
Object value = getConfigValue(keyNoPrefix, "");
Object valueUnwrapped = ConfigValueFactory.fromAnyRef(value).unwrapped();
if (!getKeysExcludedFromRendering().contains(keyNoPrefix)) {
Expand Down

0 comments on commit 2c91e9c

Please sign in to comment.