Simplify code using Java 8 features
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / CandidateListChangeListener.java
index 005de8729ee0b484c92143b28c6d8c9162404f56..a7be8c50d2cf949244143d8e5fad4f0569d45c90 100644 (file)
@@ -93,11 +93,7 @@ class CandidateListChangeListener implements DOMDataTreeChangeListener {
     }
 
     private Collection<String> addToCurrentCandidates(YangInstanceIdentifier entityId, String newCandidate) {
-        Collection<String> candidates = currentCandidates.get(entityId);
-        if (candidates == null) {
-            candidates = new LinkedHashSet<>();
-            currentCandidates.put(entityId, candidates);
-        }
+        Collection<String> candidates = currentCandidates.computeIfAbsent(entityId, k -> new LinkedHashSet<>());
 
         candidates.add(newCandidate);
         return candidates;