aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
index a31558f4f9..39f04d67c6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.openecomp.sdc.vendorsoftwareproduct.utils;
import java.util.HashMap;
@@ -6,7 +22,7 @@ import java.util.Map;
import java.util.Set;
public class ComponentDependencyTracker {
- Map<String, Set<String>> store = new HashMap<>();
+ private final Map<String, Set<String>> store = new HashMap<>();
/**
* Add dependency.
@@ -17,14 +33,9 @@ public class ComponentDependencyTracker {
public void addDependency(String dependent, String dependsOn) {
if (dependent != null && dependsOn != null && dependent.trim().length() > 0 && dependsOn.trim()
.length() > 0) {
- dependent = dependent.toLowerCase();
- dependsOn = dependsOn.toLowerCase();
- Set<String> dependsOnList = store.get(dependent);
- if (dependsOnList == null) {
- dependsOnList = new HashSet<>();
- store.put(dependent, dependsOnList);
- }
- dependsOnList.add(dependsOn);
+ Set<String> dependsOnList = store
+ .computeIfAbsent(dependent.toLowerCase(), k -> new HashSet<>());
+ dependsOnList.add(dependsOn.toLowerCase());
}
}