aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java
index 6337ff2..be14852 100644
--- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java
+++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java
@@ -16,7 +16,6 @@ public class ConfigProfileGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigProfileGenerator.class);
-
private static final String PROFILE_NOT_COMPLETE_WARNING_MESSAGE = "The default values for a incoming " +
"mzs:DeliveryRequest/Config element could not be extracted from configuration because some values were " +
"missing.";
@@ -50,7 +49,11 @@ public class ConfigProfileGenerator {
this.defaultConfigKey = defaultConfigKey;
}
-
+ /**
+ * Generate a map of Config profiles on the basis of supplied properties.
+ *
+ * @return map with profiles, indexed by ProfileId
+ */
public Map<String, ConfigType> generate() {
var groupedKeys = properties.getPropertyNames()
@@ -60,7 +63,7 @@ public class ConfigProfileGenerator {
.collect(groupingBy(this::keepPrefix, mapping(this::removePrefix, toSet())));
var profiles = groupedKeys.entrySet().stream()
- .collect(toMap(Entry::getKey, this::createConfigFromEnv));
+ .collect(toUnmodifiableMap(Entry::getKey, this::createConfigFromEnv));
var defaultProfile = profiles.get(defaultConfigKey);
@@ -118,7 +121,7 @@ public class ConfigProfileGenerator {
public static class ConfigProfileGeneratorBuilder {
private SpringPropertiesFacade properties;
private ConfigUtil util;
- private boolean verifyCompletenessOfDefaultConfiguration = true;
+ private boolean verify = true;
private String profilePrefix = "delivery-request-configuration-profiles";
private String defaultConfigKey = "default";
@@ -132,8 +135,9 @@ public class ConfigProfileGenerator {
return this;
}
- public ConfigProfileGeneratorBuilder withVerifyCompletenessOfDefaultConfiguration(boolean verifyCompletenessOfDefaultConfiguration) {
- this.verifyCompletenessOfDefaultConfiguration = verifyCompletenessOfDefaultConfiguration;
+ public ConfigProfileGeneratorBuilder withVerifyCompletenessOfDefaultConfiguration(
+ boolean verify) {
+ this.verify = verify;
return this;
}
@@ -148,9 +152,10 @@ public class ConfigProfileGenerator {
}
public ConfigProfileGenerator build() {
- if(properties == null || util == null || profilePrefix == null || defaultConfigKey == null)
- throw new IllegalArgumentException("Cannot build ConfigProfileGenerator: One or more arguments are null.");
- return new ConfigProfileGenerator(properties, util, verifyCompletenessOfDefaultConfiguration, profilePrefix, defaultConfigKey);
+ if (properties == null || util == null || profilePrefix == null || defaultConfigKey == null)
+ throw new IllegalArgumentException("Cannot build ConfigProfileGenerator: " +
+ "One or more arguments are null.");
+ return new ConfigProfileGenerator(properties, util, verify, profilePrefix, defaultConfigKey);
}
}
}