Enable checkstyle rule to catch variables that hide fields

Enable the checkstyle "HiddenFields" rule and fix any issues
that it detects.  Suppress these violations for parameters
to setters and constructors.

Added support for the checkstyle comment suppression module
// CHECKSTYLE:OFF and //CHECKSTYLE:ON are now
supported.

Suppressed HiddenField checks for net.onrc.onos.core.packet.*
rather than fix them.  These APIs are designed to
require formal parameters and local members having
the same name.

Change-Id: Ibc057603a934842d9c9b9b668f55bc5f5519e7f6
diff --git a/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java b/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
index 5552f59..cfdb02b 100644
--- a/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
+++ b/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
@@ -143,9 +143,9 @@
         this.isPortIdsModified = true;
     }
 
-    public void addAllToPortIds(final Collection<byte[]> portIds) {
+    public void addAllToPortIds(final Collection<byte[]> newPortIds) {
         // TODO: Should we copy portId, or reference is OK.
-        isPortIdsModified |= this.portIds.addAll(portIds);
+        isPortIdsModified |= portIds.addAll(newPortIds);
     }
 
     /**
diff --git a/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java b/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
index 94f509f..2efa0b0 100644
--- a/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
+++ b/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
@@ -144,11 +144,12 @@
      * Deserialize using value and version stored in data store.
      *
      * @param bytes   serialized bytes
-     * @param version version of this {@code bytes}
+     * @param dataStoreVersion version of this {@code bytes}
      * @return true if success
      */
-    public boolean deserialize(final byte[] bytes, final long version) {
-        this.version = version;
+    public boolean deserialize(final byte[] bytes,
+                               final long dataStoreVersion) {
+        version = dataStoreVersion;
         return deserialize(bytes);
     }
 
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
index fe29efd..0be7362 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -445,20 +445,20 @@
     /**
      * Set parameters needed for sending messages.
      *
-     * @param context    FloodlightContext used for sending messages.
+     * @param floodlightContext    FloodlightContext used for sending messages.
      *                   If null, FlowPusher uses default context.
      * @param modContext FloodlightModuleContext used for acquiring
      *                   ThreadPoolService and registering MessageListener.
-     * @param factory    Factory object to create OFMessage objects.
+     * @param basicFactory    Factory object to create OFMessage objects.
      * @param damper     Message damper used for sending messages.
      *                   If null, FlowPusher creates its own damper object.
      */
-    public void init(FloodlightContext context,
+    public void init(FloodlightContext floodlightContext,
                      FloodlightModuleContext modContext,
-                     BasicFactory factory,
+                     BasicFactory basicFactory,
                      OFMessageDamper damper) {
-        this.context = context;
-        this.factory = factory;
+        context = floodlightContext;
+        factory = basicFactory;
         this.threadPool = modContext.getServiceImpl(IThreadPoolService.class);
         IFloodlightProviderService flservice
                 = modContext.getServiceImpl(IFloodlightProviderService.class);
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
index 9ef1a1f..da8c9d2 100755
--- a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
@@ -68,8 +68,8 @@
 
         public void flushLog() {
             log("finish");
-            for (PerfLog log : logData) {
-                log.logThis();
+            for (PerfLog perfLog : logData) {
+                perfLog.logThis();
             }
             logData.clear();
         }
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
index a764f1c..aeabb3a 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -1202,14 +1202,14 @@
     /**
      * Removes links from memory and storage.
      *
-     * @param links The List of @LinkTuple to delete.
+     * @param linksToDelete The List of @LinkTuple to delete.
      */
-    protected void deleteLinks(List<Link> links, String reason) {
+    protected void deleteLinks(List<Link> linksToDelete, String reason) {
         NodePortTuple srcNpt, dstNpt;
 
         lock.writeLock().lock();
         try {
-            for (Link lt : links) {
+            for (Link lt : linksToDelete) {
                 srcNpt = new NodePortTuple(lt.getSrc(), lt.getSrcPort());
                 dstNpt = new NodePortTuple(lt.getDst(), lt.getDstPort());
 
diff --git a/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java b/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
index 4b0a0f3..989d2c1 100755
--- a/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
@@ -32,7 +32,7 @@
 
     protected IRestApiService restApi;
 
-    protected String controllerId = null;
+    protected String registeredControllerId = null;
     protected Map<String, ControlChangeCallback> switchCallbacks;
 
     //
@@ -43,7 +43,7 @@
     @Override
     public void requestControl(long dpid, ControlChangeCallback cb)
             throws RegistryException {
-        if (controllerId == null) {
+        if (registeredControllerId == null) {
             throw new RuntimeException(
                     "Must register a controller before calling requestControl");
         }
@@ -81,29 +81,29 @@
 
     @Override
     public String getControllerId() {
-        return controllerId;
+        return registeredControllerId;
     }
 
     @Override
     public void registerController(String controllerId)
             throws RegistryException {
-        if (this.controllerId != null) {
+        if (registeredControllerId != null) {
             throw new RegistryException(
-                    "Controller already registered with id " + this.controllerId);
+                    "Controller already registered with id " + registeredControllerId);
         }
-        this.controllerId = controllerId;
+        registeredControllerId = controllerId;
     }
 
     @Override
     public Collection<String> getAllControllers() throws RegistryException {
         List<String> l = new ArrayList<String>();
-        l.add(controllerId);
+        l.add(registeredControllerId);
         return l;
     }
 
     @Override
     public String getControllerForSwitch(long dpid) throws RegistryException {
-        return (switchCallbacks.get(HexString.toHexString(dpid)) != null) ? controllerId : null;
+        return (switchCallbacks.get(HexString.toHexString(dpid)) != null) ? registeredControllerId : null;
     }
 
     @Override
@@ -114,7 +114,7 @@
         for (String strSwitch : switchCallbacks.keySet()) {
             log.debug("Switch _{}", strSwitch);
             List<ControllerRegistryEntry> list = new ArrayList<ControllerRegistryEntry>();
-            list.add(new ControllerRegistryEntry(controllerId, 0));
+            list.add(new ControllerRegistryEntry(registeredControllerId, 0));
 
             switches.put(strSwitch, list);
         }
diff --git a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
index 070850d..230b39b 100755
--- a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
@@ -71,9 +71,9 @@
     private static final String SERVICES_PATH = "/"; //i.e. the root of our namespace
     private static final String CONTROLLER_SERVICE_NAME = "controllers";
 
-    protected CuratorFramework client;
+    protected CuratorFramework curatorFrameworkClient;
 
-    protected PathChildrenCache switchCache;
+    protected PathChildrenCache rootSwitchCache;
 
     protected ConcurrentHashMap<String, SwitchLeadershipData> switches;
     protected Map<String, PathChildrenCache> switchPathCaches;
@@ -250,7 +250,7 @@
             throw new RegistryException("Already contesting control for " + dpidStr);
         }
 
-        LeaderLatch latch = new LeaderLatch(client, latchPath, controllerId);
+        LeaderLatch latch = new LeaderLatch(curatorFrameworkClient, latchPath, controllerId);
         SwitchLeaderListener listener = new SwitchLeaderListener(dpidStr);
         latch.addListener(listener);
 
@@ -418,7 +418,7 @@
     }
 
     @Override
-    public Collection<Long> getSwitchesControlledByController(String controllerId) {
+    public Collection<Long> getSwitchesControlledByController(String controller) {
         //TODO remove this if not needed
         throw new RuntimeException("Not yet implemented");
     }
@@ -444,12 +444,12 @@
 
             for (ChildData d : entry.getValue().getCurrentData()) {
 
-                String controllerId = new String(d.getData(), Charsets.UTF_8);
+                String childsControllerId = new String(d.getData(), Charsets.UTF_8);
 
                 String[] splitted = d.getPath().split("-");
                 int sequenceNumber = Integer.parseInt(splitted[splitted.length - 1]);
 
-                contendingControllers.add(new ControllerRegistryEntry(controllerId, sequenceNumber));
+                contendingControllers.add(new ControllerRegistryEntry(childsControllerId, sequenceNumber));
             }
 
             Collections.sort(contendingControllers);
@@ -546,9 +546,9 @@
 
         //Read the Zookeeper connection string from the config
         Map<String, String> configParams = context.getConfigParams(this);
-        String connectionString = configParams.get("connectionString");
-        if (connectionString != null) {
-            this.connectionString = connectionString;
+        String connectionStringParam = configParams.get("connectionString");
+        if (connectionStringParam != null) {
+            connectionString = connectionStringParam;
         }
         log.info("Setting Zookeeper connection string to {}", this.connectionString);
 
@@ -559,23 +559,23 @@
         switchPathCaches = new ConcurrentHashMap<String, PathChildrenCache>();
 
         RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
-        client = CuratorFrameworkFactory.newClient(this.connectionString,
+        curatorFrameworkClient = CuratorFrameworkFactory.newClient(this.connectionString,
                 SESSION_TIMEOUT, CONNECTION_TIMEOUT, retryPolicy);
 
-        client.start();
-        client = client.usingNamespace(namespace);
+        curatorFrameworkClient.start();
+        curatorFrameworkClient = curatorFrameworkClient.usingNamespace(namespace);
 
         distributedIdCounter = new DistributedAtomicLong(
-                client,
+                curatorFrameworkClient,
                 ID_COUNTER_PATH,
                 new RetryOneTime(100));
 
-        switchCache = new PathChildrenCache(client, switchLatchesPath, true);
-        switchCache.getListenable().addListener(switchPathCacheListener);
+        rootSwitchCache = new PathChildrenCache(curatorFrameworkClient, switchLatchesPath, true);
+        rootSwitchCache.getListenable().addListener(switchPathCacheListener);
 
         //Build the service discovery object
         serviceDiscovery = ServiceDiscoveryBuilder.builder(ControllerService.class)
-                .client(client).basePath(SERVICES_PATH).build();
+                .client(curatorFrameworkClient).basePath(SERVICES_PATH).build();
 
         //We read the list of services very frequently (GUI periodically queries them)
         //so we'll cache them to cut down on Zookeeper queries.
@@ -588,7 +588,7 @@
             serviceCache.start();
 
             //Don't prime the cache, we want a notification for each child node in the path
-            switchCache.start(StartMode.NORMAL);
+            rootSwitchCache.start(StartMode.NORMAL);
         } catch (Exception e) {
             throw new FloodlightModuleException("Error initialising ZookeeperRegistry: "
                     + e.getMessage());
@@ -614,7 +614,7 @@
         if (controllerId == null) {
             log.error("Error on startup: unknown ControllerId");
         }
-        clusterLeaderLatch = new LeaderLatch(client,
+        clusterLeaderLatch = new LeaderLatch(curatorFrameworkClient,
                 CLUSTER_LEADER_PATH,
                 controllerId);
         clusterLeaderListener = new ClusterLeaderListener();
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
index 869b282..bc1fc9a 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -137,12 +137,12 @@
             //
             // For now, as a shortcut we read it from the datagrid
             //
-            Collection<TopologyEvent> topologyEvents =
+            Collection<TopologyEvent> allTopologyEvents =
                     eventChannel.getAllEntries();
             Collection<EventEntry<TopologyEvent>> collection =
                     new LinkedList<EventEntry<TopologyEvent>>();
 
-            for (TopologyEvent topologyEvent : topologyEvents) {
+            for (TopologyEvent topologyEvent : allTopologyEvents) {
                 EventEntry<TopologyEvent> eventEntry =
                         new EventEntry<TopologyEvent>(EventEntry.Type.ENTRY_ADD,
                                 topologyEvent);
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryErrorState.java b/src/main/java/net/onrc/onos/core/util/FlowEntryErrorState.java
index fa12055..4744baa 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryErrorState.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryErrorState.java
@@ -71,12 +71,12 @@
     /**
      * Set the values of the error type and code.
      *
-     * @param type the error type to use.
-     * @param code the error code to use.
+     * @param newType the error type to use.
+     * @param newCode the error code to use.
      */
-    public void setValue(short type, short code) {
-        this.type = type;
-        this.code = code;
+    public void setValue(short newType, short newCode) {
+        type = newType;
+        code = newCode;
     }
 
     /**
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java b/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java
index 3b603e9..eabf401 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java
@@ -46,10 +46,10 @@
         /**
          * Enable the matching for a given value.
          *
-         * @param value the value to set.
+         * @param newValue the value to set.
          */
-        public void enableMatch(T value) {
-            this.value = value;
+        public void enableMatch(T newValue) {
+            this.value = newValue;
             this.enabled = true;
         }
 
@@ -152,11 +152,11 @@
     /**
      * Enable the matching on input switch port.
      *
-     * @param inPort the input switch port value to enable for matching.
+     * @param newInPort the input switch port value to enable for matching.
      */
     @JsonProperty("inPort")
-    public void enableInPort(Port inPort) {
-        this.inPort = new Field<Port>(inPort);
+    public void enableInPort(Port newInPort) {
+        this.inPort = new Field<Port>(newInPort);
     }
 
     /**
@@ -195,11 +195,11 @@
     /**
      * Enable the matching on source MAC address.
      *
-     * @param srcMac the source MAC address value to enable for matching.
+     * @param newSrcMac the source MAC address value to enable for matching.
      */
     @JsonProperty("srcMac")
-    public void enableSrcMac(MACAddress srcMac) {
-        this.srcMac = new Field<MACAddress>(srcMac);
+    public void enableSrcMac(MACAddress newSrcMac) {
+        this.srcMac = new Field<MACAddress>(newSrcMac);
     }
 
     /**
@@ -238,11 +238,11 @@
     /**
      * Enable the matching on destination MAC address.
      *
-     * @param dstMac the destination MAC address value to enable for matching.
+     * @param newDstMac the destination MAC address value to enable for matching.
      */
     @JsonProperty("dstMac")
-    public void enableDstMac(MACAddress dstMac) {
-        this.dstMac = new Field<MACAddress>(dstMac);
+    public void enableDstMac(MACAddress newDstMac) {
+        this.dstMac = new Field<MACAddress>(newDstMac);
     }
 
     /**
@@ -281,12 +281,12 @@
     /**
      * Enable the matching on Ethernet frame type.
      *
-     * @param ethernetFrameType the Ethernet frame type value to enable for
+     * @param newEthernetFrameType the Ethernet frame type value to enable for
      *                          matching.
      */
     @JsonProperty("ethernetFrameType")
-    public void enableEthernetFrameType(Short ethernetFrameType) {
-        this.ethernetFrameType = new Field<Short>(ethernetFrameType);
+    public void enableEthernetFrameType(Short newEthernetFrameType) {
+        this.ethernetFrameType = new Field<Short>(newEthernetFrameType);
     }
 
     /**
@@ -325,11 +325,11 @@
     /**
      * Enable the matching on VLAN ID.
      *
-     * @param vlanId the VLAN ID value to enable for matching.
+     * @param newVlanId the VLAN ID value to enable for matching.
      */
     @JsonProperty("vlanId")
-    public void enableVlanId(Short vlanId) {
-        this.vlanId = new Field<Short>(vlanId);
+    public void enableVlanId(Short newVlanId) {
+        this.vlanId = new Field<Short>(newVlanId);
     }
 
     /**
@@ -368,11 +368,11 @@
     /**
      * Enable the matching on VLAN priority.
      *
-     * @param vlanPriority the VLAN priority value to enable for matching.
+     * @param newVlanPriority the VLAN priority value to enable for matching.
      */
     @JsonProperty("vlanPriority")
-    public void enableVlanPriority(Byte vlanPriority) {
-        this.vlanPriority = new Field<Byte>(vlanPriority);
+    public void enableVlanPriority(Byte newVlanPriority) {
+        this.vlanPriority = new Field<Byte>(newVlanPriority);
     }
 
     /**
@@ -411,11 +411,11 @@
     /**
      * Enable the matching on source IPv4 prefix.
      *
-     * @param srcIPv4Net the source IPv4 prefix value to enable for matching.
+     * @param newSrcIPv4Net the source IPv4 prefix value to enable for matching.
      */
     @JsonProperty("srcIPv4Net")
-    public void enableSrcIPv4Net(IPv4Net srcIPv4Net) {
-        this.srcIPv4Net = new Field<IPv4Net>(srcIPv4Net);
+    public void enableSrcIPv4Net(IPv4Net newSrcIPv4Net) {
+        this.srcIPv4Net = new Field<IPv4Net>(newSrcIPv4Net);
     }
 
     /**
@@ -454,12 +454,12 @@
     /**
      * Enable the matching on destination IPv4 prefix.
      *
-     * @param dstIPv4Net the destination IPv4 prefix value to enable for
+     * @param newDstIPv4Net the destination IPv4 prefix value to enable for
      *                   matching.
      */
     @JsonProperty("dstIPv4Net")
-    public void enableDstIPv4Net(IPv4Net dstIPv4Net) {
-        this.dstIPv4Net = new Field<IPv4Net>(dstIPv4Net);
+    public void enableDstIPv4Net(IPv4Net newDstIPv4Net) {
+        this.dstIPv4Net = new Field<IPv4Net>(newDstIPv4Net);
     }
 
     /**
@@ -498,11 +498,11 @@
     /**
      * Enable the matching on IP protocol.
      *
-     * @param ipProto the IP protocol value to enable for matching.
+     * @param newIpProto the IP protocol value to enable for matching.
      */
     @JsonProperty("ipProto")
-    public void enableIpProto(Byte ipProto) {
-        this.ipProto = new Field<Byte>(ipProto);
+    public void enableIpProto(Byte newIpProto) {
+        this.ipProto = new Field<Byte>(newIpProto);
     }
 
     /**
@@ -541,11 +541,11 @@
     /**
      * Enable the matching on IP ToS (DSCP field, 6 bits).
      *
-     * @param ipToS the IP ToS value to enable for matching.
+     * @param newIpToS the IP ToS value to enable for matching.
      */
     @JsonProperty("ipToS")
-    public void enableIpToS(Byte ipToS) {
-        this.ipToS = new Field<Byte>(ipToS);
+    public void enableIpToS(Byte newIpToS) {
+        this.ipToS = new Field<Byte>(newIpToS);
     }
 
     /**
@@ -584,11 +584,11 @@
     /**
      * Enable the matching on source TCP/UDP port.
      *
-     * @param srcTcpUdpPort the source TCP/UDP port to enable for matching.
+     * @param newSrcTcpUdpPort the source TCP/UDP port to enable for matching.
      */
     @JsonProperty("srcTcpUdpPort")
-    public void enableSrcTcpUdpPort(Short srcTcpUdpPort) {
-        this.srcTcpUdpPort = new Field<Short>(srcTcpUdpPort);
+    public void enableSrcTcpUdpPort(Short newSrcTcpUdpPort) {
+        this.srcTcpUdpPort = new Field<Short>(newSrcTcpUdpPort);
     }
 
     /**
@@ -627,12 +627,12 @@
     /**
      * Enable the matching on destination TCP/UDP port.
      *
-     * @param dstTcpUdpPort the destination TCP/UDP port to enable for
-     *                      matching.
+     * @param newDstTcpUdpPort the destination TCP/UDP port to enable for
+     *                         matching.
      */
     @JsonProperty("dstTcpUdpPort")
-    public void enableDstTcpUdpPort(Short dstTcpUdpPort) {
-        this.dstTcpUdpPort = new Field<Short>(dstTcpUdpPort);
+    public void enableDstTcpUdpPort(Short newDstTcpUdpPort) {
+        this.dstTcpUdpPort = new Field<Short>(newDstTcpUdpPort);
     }
 
     /**