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 b214526..969aa63 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 c119eb7..7f398db 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 4f122cf..ecb1f60 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 46c5a9d..d58be67 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 fc3d51c..349e68d 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 e21f6f1..31b3ec6 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 0237b9c..26bdbcc 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 35c54e7..f85b7b4 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 57286fe..d018823 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 551769a..0b394bf 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 46623c3..0ea8855 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 c570377..e20e22a 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 {

©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.