Use ImmutableMap instead of Collections.emptyMap() 57/46357/1
authorRobert Varga <rovarga@cisco.com>
Tue, 20 Sep 2016 01:51:07 +0000 (03:51 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 3 Oct 2016 11:35:57 +0000 (13:35 +0200)
ImmutableMap behaves nicely when it meets copying and can
be checked for.

Change-Id: I2e0b52b8ea83c69e4ace3364904975b806a67aae
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 474a3348cb0a272c6c6dde7089c68497ad619198)

dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/WriteableSubshardBoundaryNode.java
dom/mdsal-dom-inmemory-datastore/src/test/java/org/opendaylight/mdsal/dom/store/inmemory/WriteableSubshardBoundaryNodeTest.java

index 73c5681ba49a686c5700097bc7944e8d776e4db3..2aefbd5fa9c8ba324c5a7333029dee4eb40a63c1 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.mdsal.dom.store.inmemory;
 
 import com.google.common.base.Preconditions;
-import java.util.Collections;
+import com.google.common.collect.ImmutableMap;
 import java.util.Map;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -69,6 +69,6 @@ final class WriteableSubshardBoundaryNode extends WriteableModificationNode {
 
     @Override
     Map<PathArgument, WriteableModificationNode> getChildrenWithSubshards() {
-        return Collections.emptyMap();
+        return ImmutableMap.of();
     }
 }
index 443a972d9c6d28a9279b783ef0a4a70e64afe2f8..de9b073f657a3164c466ecfc4c9225efdfa94355 100644 (file)
@@ -21,7 +21,7 @@ import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.DOM_DATA_TREE_
 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.DOM_DATA_TREE_WRITE_CURSOR;
 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.resetMocks;
 
-import java.util.Collections;
+import com.google.common.collect.ImmutableMap;
 import org.junit.After;
 import org.junit.Test;
 
@@ -62,7 +62,7 @@ public class WriteableSubshardBoundaryNodeTest {
                 WriteableSubshardBoundaryNode.from(FOREIGN_SHARD_MODIFICATION_CONTEXT);
 
         assertNotNull(writeableSubshardBoundaryNode.getChildrenWithSubshards());
-        assertSame(Collections.emptyMap(),writeableSubshardBoundaryNode.getChildrenWithSubshards());
+        assertSame(ImmutableMap.of(), writeableSubshardBoundaryNode.getChildrenWithSubshards());
         assertEquals(DOM_DATA_TREE_IDENTIFIER.getRootIdentifier().getLastPathArgument(),
                 writeableSubshardBoundaryNode.getIdentifier());
         assertNull(writeableSubshardBoundaryNode.getChild(null));