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 729b7d8f82202ebf9cc253980df143c2494297ac..a7be8c50d2cf949244143d8e5fad4f0569d45c90 100644 (file)
@@ -27,7 +27,7 @@ import java.util.Map.Entry;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateAdded;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateRemoved;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -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;