diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-16 14:26:03 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-16 14:26:03 +0200 |
commit | aff7c021e37e64162ce4e3fe5abd419072fb464f (patch) | |
tree | fdf3b0b7f609e6c9c42f436dda298095c7d2a5cb /src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java | |
parent | f18a151a98482093118f3b728c514b918afda8c5 (diff) | |
download | moa-zs-aff7c021e37e64162ce4e3fe5abd419072fb464f.tar.gz moa-zs-aff7c021e37e64162ce4e3fe5abd419072fb464f.tar.bz2 moa-zs-aff7c021e37e64162ce4e3fe5abd419072fb464f.zip |
Refactor + Document in preprocess
- Refactor: Move ConfigType.merge's null check to caller.
- Revise documentation of preprocess' public methods.
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.java | 23 |
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); } } } |