diff options
author | 2021-03-27 22:58:29 +0000 | |
---|---|---|
committer | 2021-03-29 07:15:14 +0000 | |
commit | 04c236567737c965545f64c9542a7d75ed6f9046 (patch) | |
tree | 8d2a3ea1bcb80b8d66603bb31a8b6877a98d84f8 /common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java | |
parent | be66acfea37b8d96cbb1b1e14592de57ec3bc4ae (diff) |
Reformat common
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3449
Change-Id: Ifa1412b8a614f7cdb4c52f05d811ab5e9cf20d83
Diffstat (limited to 'common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java')
-rw-r--r-- | common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java index 07c81e5f5b..0621561dcc 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/AggregateConfiguration.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.onap.config.impl; import static org.onap.config.Constants.LOAD_ORDER_KEY; @@ -44,17 +43,14 @@ public final class AggregateConfiguration { private final Map<String, Configuration> overrideConfig = Collections.synchronizedMap(new LinkedHashMap<>()); public void addConfig(File file) throws ConfigurationException { - addConfig(fileToUrl(file), ConfigurationUtils.getMergeStrategy(file), - ConfigurationUtils.getConfigurationBuilder(file).getConfiguration()); + addConfig(fileToUrl(file), ConfigurationUtils.getMergeStrategy(file), ConfigurationUtils.getConfigurationBuilder(file).getConfiguration()); } public void addConfig(URL url) throws ConfigurationException { - addConfig(url, ConfigurationUtils.getMergeStrategy(url), - ConfigurationUtils.getConfigurationBuilder(url).getConfiguration()); + addConfig(url, ConfigurationUtils.getMergeStrategy(url), ConfigurationUtils.getConfigurationBuilder(url).getConfiguration()); } private void addConfig(URL url, ConfigurationMode configMode, Configuration config) { - String normalizedUrl = normalize(url); if (configMode != null) { switch (configMode) { @@ -76,28 +72,24 @@ public final class AggregateConfiguration { private String normalize(URL url) { // what about Linux where paths are case sensitive? - return url.toString().toUpperCase(); + return url.toString().toUpperCase(); } private URL fileToUrl(File file) { - try { - return file.getAbsoluteFile().toURI().toURL(); + return file.getAbsoluteFile().toURI().toURL(); } catch (MalformedURLException e) { - throw new IllegalStateException("URL produced by JDK and is not expected to be malformed. File: " - + file.getAbsoluteFile()); + throw new IllegalStateException("URL produced by JDK and is not expected to be malformed. File: " + file.getAbsoluteFile()); } } public Configuration getFinalConfiguration() { - CombinedConfiguration ccRoot = new CombinedConfiguration(new MergeCombiner()); ArrayList<Configuration> tempList = new ArrayList<>(rootConfig.values()); tempList.sort(this::sortForMerge); for (Configuration conf : tempList) { ccRoot.addConfiguration(conf); } - CombinedConfiguration ccMergeRoot = new CombinedConfiguration(new MergeCombiner()); ccMergeRoot.addConfiguration(ccRoot); tempList = new ArrayList<>(mergeConfig.values()); @@ -105,13 +97,11 @@ public final class AggregateConfiguration { for (Configuration conf : tempList) { ccMergeRoot.addConfiguration(conf); } - CombinedConfiguration ccUnionRoot = new CombinedConfiguration(new UnionCombiner()); ccUnionRoot.addConfiguration(ccMergeRoot); for (Configuration conf : unionConfig.values()) { ccUnionRoot.addConfiguration(conf); } - ArrayList<Configuration> tempOverrideConfigs = new ArrayList<>(overrideConfig.values()); Collections.reverse(tempOverrideConfigs); tempOverrideConfigs.sort(this::sortForOverride); @@ -119,7 +109,6 @@ public final class AggregateConfiguration { for (Configuration conf : tempOverrideConfigs) { ccOverrideRoot.addConfiguration(conf); } - ccOverrideRoot.addConfiguration(ccUnionRoot); return ccOverrideRoot; } @@ -139,12 +128,10 @@ public final class AggregateConfiguration { } private int readLoadOrder(Configuration conf) { - String order = conf.getString(LOAD_ORDER_KEY); if (ConfigurationUtils.isBlank(order) || !order.trim().matches("\\d+")) { return 0; } - return Integer.parseInt(order.trim()); } } |