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 005de87..a7be8c5 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;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.