Fixing warnings in the sal sub-project. 76/2176/3
authorColin Dixon <ckd@us.ibm.com>
Fri, 25 Oct 2013 20:13:26 +0000 (15:13 -0500)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 31 Oct 2013 13:55:38 +0000 (13:55 +0000)
This fixes all of the warnings in this module mostly by (a) adding
full types to raw types when possible, (b) removing unused imports,
and (c) adding @SuppressWarning statements in tests where variables
are intentionally unused.

Change-Id: Iccb54cf3163ecf1c14b0473328438f43d78b32e3
Signed-off-by: Colin Dixon <ckd@us.ibm.com>
12 files changed:
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Edge.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ServiceHelper.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeConnectorTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeTableTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/PathTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/address/EthernetAddressTest.java

index b2145262d4f7228a8b6292cfd6906ac1581ec3bf..969aa630a1519f712e24af8ef0e0cd0025022635 100644 (file)
@@ -201,6 +201,7 @@ abstract public class ComponentActivatorAbstractBase implements
                         //Set the service properties to include the containerName
                         //in the service, that is fundamental for supporting
                         //multiple services just distinguished via a container
+                        @SuppressWarnings("unchecked")
                         Dictionary<String, String> serviceProps = c
                                 .getServiceProperties();
                         if (serviceProps != null) {
index c119eb79f554fc47f34f05fba02bdd17591fede5..7f398db6f12e8def650afa50be7a0ee888460906 100644 (file)
@@ -44,6 +44,7 @@ public class Edge implements Serializable {
     /**
      * Private constructor used for JAXB mapping
      */
+    @SuppressWarnings("unused")
     private Edge() {
         this.tailNodeConnector = null;
         this.headNodeConnector = null;
index 4f122cf40231edf00d2d428639ec5ef90cb1a4d8..ecb1f604d5e30c450f8613daf3328ea54f9e220a 100644 (file)
@@ -244,6 +244,7 @@ public class Node implements Serializable {
      *
      * @param type of node to be set
      */
+    @SuppressWarnings("unused")
     private void setType(String type) {
         this.nodeType = type;
         if (this.nodeIDString != null) {
@@ -280,6 +281,7 @@ public class Node implements Serializable {
      *
      * @param nodeIDString String representation for NodeID
      */
+    @SuppressWarnings("unused")
     private void setNodeIDString(String nodeIDString) {
         this.nodeIDString = nodeIDString;
         if (this.nodeType != null) {
index 46c5a9dae933baee49c47e98476a37dd9222dae5..d58be6771bb034d5cf7738b1eaa5c47caa4ec4ce 100644 (file)
@@ -97,42 +97,42 @@ public class NodeConnector implements Serializable {
         // for Unit Testing coverage
         static {
             compatibleType.put(CONTROLLER,
-                               new ImmutablePair(Short.class, null));
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class, null));
             compatibleType.put(ALL,
-                               new ImmutablePair(Short.class, null));
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class, null));
             compatibleType.put(SWSTACK,
-                               new ImmutablePair(Short.class, null));
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class, null));
             compatibleType.put(HWPATH,
-                               new ImmutablePair(Short.class, null));
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class, null));
             compatibleType.put(OPENFLOW,
-                               new ImmutablePair(Short.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class,
                                                  Node.NodeIDType.OPENFLOW));
             compatibleType.put(PCEP,
-                               new ImmutablePair(Integer.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Integer.class,
                                                  Node.NodeIDType.PCEP));
             compatibleType.put(ONEPK,
-                               new ImmutablePair(String.class,
+                               new ImmutablePair<Class<? extends Object>, String>(String.class,
                                                  Node.NodeIDType.ONEPK));
             compatibleType.put(OPENFLOW2PCEP,
-                               new ImmutablePair(Short.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class,
                                                  Node.NodeIDType.OPENFLOW));
             compatibleType.put(OPENFLOW2ONEPK,
-                               new ImmutablePair(Short.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Short.class,
                                                  Node.NodeIDType.OPENFLOW));
             compatibleType.put(PCEP2OPENFLOW,
-                               new ImmutablePair(Integer.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Integer.class,
                                                  Node.NodeIDType.PCEP));
             compatibleType.put(PCEP2ONEPK,
-                               new ImmutablePair(Integer.class,
+                               new ImmutablePair<Class<? extends Object>, String>(Integer.class,
                                                  Node.NodeIDType.PCEP));
             compatibleType.put(ONEPK2OPENFLOW,
-                               new ImmutablePair(String.class,
+                               new ImmutablePair<Class<? extends Object>, String>(String.class,
                                                  Node.NodeIDType.ONEPK));
             compatibleType.put(ONEPK2PCEP,
-                               new ImmutablePair(String.class,
+                               new ImmutablePair<Class<? extends Object>, String>(String.class,
                                                  Node.NodeIDType.ONEPK));
             compatibleType.put(PRODUCTION,
-                               new ImmutablePair(String.class,
+                               new ImmutablePair<Class<? extends Object>, String>(String.class,
                                                  Node.NodeIDType.PRODUCTION));
         }
 
@@ -186,7 +186,7 @@ public class NodeConnector implements Serializable {
             if (compatibleType.get(type) != null) {
                 return false;
             }  else {
-                compatibleType.put(type, new ImmutablePair(compatibleID,
+                compatibleType.put(type, new ImmutablePair<Class<? extends Object>, String>(compatibleID,
                                                            compatibleNode));
                 return true;
             }
@@ -340,6 +340,7 @@ public class NodeConnector implements Serializable {
      *
      * @param type of node to be set
      */
+    @SuppressWarnings("unused")
     private void setType(String type) {
         this.nodeConnectorType = type;
         if (this.nodeConnectorIDString != null) {
@@ -373,6 +374,7 @@ public class NodeConnector implements Serializable {
      *
      * @param nodeConnectorIDString String representation for NodeConnectorID
      */
+    @SuppressWarnings("unused")
     private void setNodeConnectorIDString(String IDStr) {
         this.nodeConnectorIDString = IDStr;
         if (this.nodeConnectorType != null) {
index fc3d51cc1f402551d992f0969c5acd8da8263327..349e68d98d56eb5bc99c58060973508cf24883c8 100644 (file)
@@ -176,11 +176,12 @@ public class NodeTable implements Serializable {
     }
 
     /**
-     * @param type the nodeTableType to set
-     *
      * Private setter for nodeConnectorType to be called by JAXB not by anyone
      * else, NodeConnector is immutable
+     *
+     * @param type the nodeTableType to set
      */
+    @SuppressWarnings("unused")
     private void setType(String type) {
         this.nodeTableType = type;
         if (this.nodeTableIDString != null) {
index e21f6f14720d9d510d72cf65ccc7ed1159acae14..31b3ec6a5a164c96cc1c8ea04aa06e35b8197eab 100644 (file)
@@ -41,6 +41,7 @@ public class Path implements Serializable {
     /**
      * Private constructor used for JAXB mapping
      */
+    @SuppressWarnings("unused")
     private Path() {
         this.edges = null;
     }
index 0237b9c499a599ffb646e7252aa723a8e18cd462..26bdbcca84873f46de388b9b431b46a990a4e9db 100644 (file)
@@ -67,7 +67,7 @@ public class ServiceHelper {
     public static boolean registerGlobalService(Class<?> clazz,
                                                 Object instance,
                                                 Dictionary<String, Object> properties) {
-        ServiceRegistration registration = registerGlobalServiceWReg(clazz, instance, properties);
+        ServiceRegistration<?> registration = registerGlobalServiceWReg(clazz, instance, properties);
         if (registration == null) {
             logger.error("Failed to register {} for instance {}", clazz, instance);
             return false;
@@ -87,7 +87,7 @@ public class ServiceHelper {
      * registration
      * @return the ServiceRegistration if registration happened, null otherwise
      */
-    public static ServiceRegistration registerServiceWReg(Class<?> clazz, String containerName,
+    public static ServiceRegistration<?> registerServiceWReg(Class<?> clazz, String containerName,
                                                           Object instance, Dictionary<String, Object> properties) {
         if (properties == null) {
             properties = (Dictionary<String, Object>) new Hashtable<String, Object>();
@@ -107,7 +107,7 @@ public class ServiceHelper {
      * registration
      * @return the ServiceRegistration if registration happened, null otherwise
      */
-    public static ServiceRegistration registerGlobalServiceWReg(Class<?> clazz,
+    public static ServiceRegistration<?> registerGlobalServiceWReg(Class<?> clazz,
                                                                 Object instance,
                                                                 Dictionary<String, Object> properties) {
         try {
@@ -117,7 +117,7 @@ public class ServiceHelper {
                 return null;
             }
 
-            ServiceRegistration registration = bCtx.registerService(clazz.getName(), instance, properties);
+            ServiceRegistration<?> registration = bCtx.registerService(clazz.getName(), instance, properties);
             return registration;
         } catch (Exception e) {
             logger.error("Exception {} while registering the service {}",
@@ -206,7 +206,7 @@ public class ServiceHelper {
             BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
                     .getBundleContext();
 
-            ServiceReference[] services = null;
+            ServiceReference<?>[] services = null;
             if (serviceFilter != null) {
                 services = bCtx.getServiceReferences(clazz.getName(),
                         "(&(containerName=" + containerName + ")"
@@ -244,7 +244,7 @@ public class ServiceHelper {
             BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
                     .getBundleContext();
 
-            ServiceReference[] services = bCtx.getServiceReferences(clazz
+            ServiceReference<?>[] services = bCtx.getServiceReferences(clazz
                     .getName(), serviceFilter);
 
             if (services != null) {
index 35c54e79e387779eac7c0540084badb2da0b5ebc..f85b7b4b01c5651c274bcbdb85d9ec33efa936ac 100644 (file)
@@ -26,6 +26,7 @@ public class NodeConnectorTest {
     public void testNodeConnectorOpenFlowOfWrongType() {
         try {
             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
+            @SuppressWarnings("unused")
             NodeConnector of1 = new NodeConnector(
                     NodeConnector.NodeConnectorIDType.OPENFLOW, new String(
                             "0xDEADBEEFCAFE0001L"), n1);
@@ -45,6 +46,7 @@ public class NodeConnectorTest {
     public void testNodeConnectorONEPKOfWrongType() {
         try {
             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
+            @SuppressWarnings("unused")
             NodeConnector onepk1 = new NodeConnector(
                     NodeConnector.NodeConnectorIDType.ONEPK, new Long(
                             0xDEADBEEFCAFE0001L), n1);
@@ -64,6 +66,7 @@ public class NodeConnectorTest {
     public void testNodeConnectorPCEPOfWrongType() {
         try {
             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
+            @SuppressWarnings("unused")
             NodeConnector pcep1 = new NodeConnector(
                     NodeConnector.NodeConnectorIDType.PCEP, new Long(
                             0xDEADBEEFCAFE0001L), n1);
@@ -310,6 +313,7 @@ public class NodeConnectorTest {
         }
     }
 
+    @SuppressWarnings("unused")
     @Test
     public void testIncompatibleNodes() {
         try {
index 57286fe1402c05dcd74f384cf4adba0c6f77a9a7..d01882369843c5bc11576a5ad02ef8614991634c 100644 (file)
@@ -16,6 +16,7 @@ public class NodeTableTest {
     public void testNodeTableOpenFlowOfWrongType() {
         try {
             Node node = NodeCreator.createOFNode((long) 20);
+            @SuppressWarnings("unused")
             NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, "name", node);
 
             // If we reach this point the exception was not raised
index 551769a55790cce97759f5a9258e217b89e71095..0b394bf9ec6354d4822474162907ae3a6e0ef2a8 100644 (file)
@@ -24,6 +24,7 @@ public class NodeTest {
     @Test
     public void testNodeOpenFlowOfWrongType() {
         try {
+            @SuppressWarnings("unused")
             Node of1 = new Node(Node.NodeIDType.OPENFLOW, new String(
                     "0xDEADBEEFCAFE0001L"));
 
@@ -41,6 +42,7 @@ public class NodeTest {
     @Test
     public void testNodeONEPKOfWrongType() {
         try {
+            @SuppressWarnings("unused")
             Node onepk1 = new Node(Node.NodeIDType.ONEPK, new Long(
                     0xDEADBEEFCAFE0001L));
 
@@ -58,6 +60,7 @@ public class NodeTest {
     @Test
     public void testNodePCEPOfWrongType() {
         try {
+            @SuppressWarnings("unused")
             Node pcep1 = new Node(Node.NodeIDType.PCEP, new Long(
                     0xDEADBEEFCAFE0001L));
 
@@ -411,6 +414,7 @@ public class NodeTest {
         // created
         Node.NodeIDType.unRegisterIDType("FOO");
         try {
+            @SuppressWarnings("unused")
             Node n = new Node("FOO", new Integer(0xCAFE));
 
             // If we reach here, something didn't go fine, an
index 46623c3df6338ffb1622283af05e489dbd75d3a8..0ea88558ded7e0113e283b520f61bc426aa735ea 100644 (file)
@@ -66,6 +66,7 @@ public class PathTest {
         }
 
         try {
+            @SuppressWarnings("unused")
             Path res = new Path(edges);
         } catch (ConstructionException e) {
             // Exception is NOT expected if raised test will fail
@@ -78,6 +79,7 @@ public class PathTest {
         edges.remove(2);
 
         try {
+            @SuppressWarnings("unused")
             Path res = new Path(edges);
             // Exception is expected if not raised test will fail
             Assert.assertTrue(false);
@@ -231,7 +233,8 @@ public class PathTest {
     @Test
     public void testPathEmpty() {
         try {
-            Path path = new Path(new LinkedList());
+            @SuppressWarnings("unused")
+            Path path = new Path(new LinkedList<Edge>());
             // Exception is expected if not raised test will fail
             Assert.assertTrue(false);
         } catch (ConstructionException e) {
@@ -253,6 +256,7 @@ public class PathTest {
 
             Edge e0 = new Edge(c0, c1);
 
+            @SuppressWarnings("unused")
             Path path = new Path(Arrays.asList(e0));
         } catch (ConstructionException e) {
             // Exception is NOT expected if raised test will fail
index c5703776a3aa69f3c32100f8fffb4db0b400f9a3..e20e22a1819dc034a9db0ac01be4a37b6e241966 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.controller.sal.core.ConstructionException;
 public class EthernetAddressTest {
     @Test
     public void testNonValidConstructor() {
+        @SuppressWarnings("unused")
         EthernetAddress ea1;
         // Null input array
         try {