Fix use of raw Collections.EMPTY_{LIST,SET} 90/93090/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 16 Oct 2020 08:50:29 +0000 (10:50 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 16 Oct 2020 08:54:23 +0000 (10:54 +0200)
Modernizer is rightly pointing out this use of constant, which also
causes some raw type warnings. Fix that up.

Change-Id: I5749db43f6d3fa21821180409d83109a43ab34a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/EmptyDependencyGetter.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortUpdateCommand.java

index ee23847342f5e565c77a26c77cba176c46f231d6..6332a6f9daa7480c0a9c2bfc5cf449138e30aa89 100644 (file)
@@ -340,7 +340,7 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I> & DataOb
         List<T> data1 = getData(include);
         List<T> data2 = diffOf(node1, node2, compareKeyOnly);
         if (HwvtepSouthboundUtil.isEmpty(data1) && HwvtepSouthboundUtil.isEmpty(data2)) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
         List<T> result = new ArrayList<>(data1);
         result.addAll(data2);
@@ -354,14 +354,14 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I> & DataOb
         List<T> list2 = getData(node2);
 
         if (HwvtepSouthboundUtil.isEmpty(list1)) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
         if (HwvtepSouthboundUtil.isEmpty(list2)) {
-            return HwvtepSouthboundUtil.isEmpty(list1) ? Collections.EMPTY_LIST : list1;
+            return HwvtepSouthboundUtil.isEmpty(list1) ? Collections.emptyList() : list1;
         }
 
-        Map<Object, T> map1 = list1.stream().collect(Collectors.toMap(ele -> ele.key(), ele -> ele));
-        Map<Object, T> map2 = list2.stream().collect(Collectors.toMap(ele -> ele.key(), ele -> ele));
+        Map<Object, T> map1 = list1.stream().collect(Collectors.toMap(Identifiable::key, ele -> ele));
+        Map<Object, T> map2 = list2.stream().collect(Collectors.toMap(Identifiable::key, ele -> ele));
         map1.entrySet().forEach(entry1 -> {
             T val2 = map2.remove(entry1.getKey());
             if (compareKeyOnly) {
@@ -507,16 +507,16 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I> & DataOb
         return new HwvtepOperationalState(getConnectionInstance());
     }
 
-    protected String getNodeKeyStr(InstanceIdentifier<T> iid) {
+    protected String getNodeKeyStr(final InstanceIdentifier<T> iid) {
         return getClassType().getTypeName() + "."
             + iid.firstKeyOf(Node.class).getNodeId().getValue() + "." + getKeyStr(iid);
     }
 
-    protected String getKeyStr(InstanceIdentifier<T> iid) {
+    protected String getKeyStr(final InstanceIdentifier<T> iid) {
         return iid.toString();
     }
 
-    protected String getLsKeyStr(InstanceIdentifier iid) {
+    protected String getLsKeyStr(final InstanceIdentifier iid) {
         return ((InstanceIdentifier<LogicalSwitches>)iid).firstKeyOf(LogicalSwitches.class)
             .getHwvtepNodeName().getValue();
     }
index 7b88b81d8e46e2d877d5f7530a1091b81349a044..6b2d8b8f298df72a7e14068fe5c130d2e85caab1 100644 (file)
@@ -21,11 +21,11 @@ public final class EmptyDependencyGetter extends UnMetDependencyGetter {
 
     @Override
     public List<InstanceIdentifier<?>> getLogicalSwitchDependencies(Identifiable data) {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     @Override
     public List<InstanceIdentifier<?>> getTerminationPointDependencies(Identifiable data) {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 }
index 75b9f1e2a878174a1c5777c01892446229a6af61..6c135470b57c497a25618f65eb11ab9d970699cc 100644 (file)
@@ -395,7 +395,7 @@ public class HwvtepOperationalState {
         if (currentTxDeletedKeys.containsKey(cls)) {
             return currentTxDeletedKeys.get(cls).keySet();
         }
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     public List<? extends Identifiable> getUpdatedData(final InstanceIdentifier<Node> key,
@@ -405,7 +405,7 @@ public class HwvtepOperationalState {
             result = modifiedData.get(key).getLeft().get(cls);
         }
         if (result == null) {
-            result = Collections.EMPTY_LIST;
+            result = Collections.emptyList();
         }
         return result;
     }
@@ -417,7 +417,7 @@ public class HwvtepOperationalState {
             result = modifiedData.get(key).getRight().get(cls);
         }
         if (result == null) {
-            result = Collections.EMPTY_LIST;
+            result = Collections.emptyList();
         }
         return result;
     }
index 58b3d15615cb316b9b39ccdf02e119b5a07a56cd..dd7f8657689fa7d48be4402edf2c54eef7bef41a 100644 (file)
@@ -47,12 +47,12 @@ public class LogicalRouterRemoveCommand
 
         for (Entry<InstanceIdentifier<Node>, List<LogicalRouters>> created: removed.entrySet()) {
             if (!HwvtepSouthboundUtil.isEmpty(created.getValue())) {
-                getOperationalState().getDeviceInfo().scheduleTransaction(new TransactCommand() {
+                getOperationalState().getDeviceInfo().scheduleTransaction(new TransactCommand<>() {
                     @Override
                     public void execute(final TransactionBuilder transactionBuilder) {
                         HwvtepConnectionInstance connectionInstance = getDeviceInfo().getConnectionInstance();
                         HwvtepOperationalState operState = new HwvtepOperationalState(
-                                connectionInstance.getDataBroker(), connectionInstance, Collections.EMPTY_LIST);
+                                connectionInstance.getDataBroker(), connectionInstance, Collections.emptyList());
                         hwvtepOperationalState = operState;
                         deviceTransaction = transactionBuilder;
                         LOG.debug("Running delete logical router in seperate tx {}", created.getKey());
index bf47aa1a691f624fd43c8579c7ad48eb6e21e296..a47f5673573580a42b3f4c64acb0b66d33056e38 100644 (file)
@@ -181,16 +181,16 @@ public class McastMacsRemoteUpdateCommand
 
     private static boolean compareLocatorSets(List<LocatorSet> locatorSet1, List<LocatorSet> locatorSet2) {
         if (locatorSet1 == null) {
-            locatorSet1 = Collections.EMPTY_LIST;
+            locatorSet1 = Collections.emptyList();
         }
         if (locatorSet2 == null) {
-            locatorSet2 = Collections.EMPTY_LIST;
+            locatorSet2 = Collections.emptyList();
         }
         if (locatorSet1.size() != locatorSet2.size()) {
             return false;
         }
-        Set set1 = Sets.newHashSet(locatorSet1);
-        Set set2 = Sets.newHashSet(locatorSet2);
+        Set<LocatorSet> set1 = Sets.newHashSet(locatorSet1);
+        Set<LocatorSet> set2 = Sets.newHashSet(locatorSet2);
         return set1.containsAll(set2);
     }
 
@@ -199,7 +199,7 @@ public class McastMacsRemoteUpdateCommand
         @Override
         public List<InstanceIdentifier<?>> getLogicalSwitchDependencies(final RemoteMcastMacs data) {
             if (data == null) {
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
             return Lists.newArrayList(data.getLogicalSwitchRef().getValue());
         }
@@ -207,7 +207,7 @@ public class McastMacsRemoteUpdateCommand
         @Override
         public List<InstanceIdentifier<?>> getTerminationPointDependencies(final RemoteMcastMacs data) {
             if (data == null || HwvtepSouthboundUtil.isEmpty(data.getLocatorSet())) {
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
             List<InstanceIdentifier<?>> locators = new ArrayList<>();
             for (LocatorSet locator: data.getLocatorSet()) {
@@ -248,7 +248,7 @@ public class McastMacsRemoteUpdateCommand
     }
 
     @Override
-    protected String getKeyStr(InstanceIdentifier<RemoteMcastMacs> iid) {
+    protected String getKeyStr(final InstanceIdentifier<RemoteMcastMacs> iid) {
         return getLsKeyStr(iid.firstKeyOf(RemoteMcastMacs.class).getLogicalSwitchRef().getValue());
     }
 }
index ce418363c4a9a05b32ad632431a258e68e396293..be27d990958b780f8e2e981529a04c539600cc4c 100644 (file)
@@ -183,7 +183,7 @@ public class UcastMacsRemoteUpdateCommand
         @Override
         public List<InstanceIdentifier<?>> getLogicalSwitchDependencies(final RemoteUcastMacs data) {
             if (data == null) {
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
             return Lists.newArrayList(data.getLogicalSwitchRef().getValue());
         }
@@ -191,7 +191,7 @@ public class UcastMacsRemoteUpdateCommand
         @Override
         public List<InstanceIdentifier<?>> getTerminationPointDependencies(final RemoteUcastMacs data) {
             if (data == null) {
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
             return Lists.newArrayList(data.getLocatorRef().getValue());
         }
@@ -214,7 +214,7 @@ public class UcastMacsRemoteUpdateCommand
     }
 
     @Override
-    protected String getKeyStr(InstanceIdentifier<RemoteUcastMacs> iid) {
+    protected String getKeyStr(final InstanceIdentifier<RemoteUcastMacs> iid) {
         return getLsKeyStr(iid.firstKeyOf(RemoteUcastMacs.class).getLogicalSwitchRef().getValue());
     }
 }
index 8c61643e670c2ff387cbc16bc70ed6142d66094a..5401c95f9e8b7200133572ae6aa61878e7dd1c7e 100644 (file)
@@ -191,11 +191,11 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
             LOG.info("addToDeviceUpdate {}", portUpdate);
             getDeviceInfo().updateDeviceOperData(VlanBindings.class, tpPath,
                     portUpdate.getUuid(), portUpdate);
-            getDeviceInfo().scheduleTransaction((transactionBuilder) -> {
+            getDeviceInfo().scheduleTransaction(transactionBuilder -> {
                 InstanceIdentifier psIid = tpPath.firstIdentifierOf(Node.class);
                 HwvtepOperationalState operState = new HwvtepOperationalState(getOvsdbConnectionInstance());
                 PhysicalPortUpdateCommand portUpdateCommand = new PhysicalPortUpdateCommand(
-                        operState, Collections.EMPTY_LIST);
+                        operState, Collections.emptyList());
                 TerminationPoint cfgPoint = (TerminationPoint) data.getData();
                 portUpdateCommand.updatePhysicalPort(transactionBuilder, psIid,
                             Lists.newArrayList(cfgPoint));