Fix up some checkstyle/PMD complaints in Metrics code

Change-Id: Ie62062fad71225d85f3d70142d3a72cbc3003b47
diff --git a/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java b/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java
index 6c8cad2..a299407 100644
--- a/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java
+++ b/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java
@@ -48,6 +48,17 @@
 public final class OnosMetrics {
 
     /**
+     * Registry to hold the Components defined in the system.
+     */
+    private static ConcurrentMap<String, MetricsComponent> componentsRegistry =
+            new ConcurrentHashMap<>();
+
+    /**
+     * Registry for the Metrics objects created in the system.
+     */
+    private static final MetricRegistry METRICS_REGISTRY = new MetricRegistry();
+
+    /**
      * Hide constructor.  The only way to get the registry is through the
      * singleton getter.
      */
@@ -95,11 +106,17 @@
         private final String name;
 
         /**
+         * Registry to hold the Features defined in this Component.
+         */
+        private final ConcurrentMap<String, MetricsFeature> featuresRegistry =
+                new ConcurrentHashMap<>();
+
+        /**
          * Constructs a component from a name.
          *
          * @param newName name of the component
          */
-        private Component(final String newName) {
+        Component(final String newName) {
             name = newName;
         }
 
@@ -108,12 +125,6 @@
             return name;
         }
 
-        /**
-         * Registry to hold the Features defined in this Component.
-         */
-        private ConcurrentMap<String, MetricsFeature> featuresRegistry =
-                new ConcurrentHashMap<>();
-
         @Override
         public MetricsFeature registerFeature(final String featureName) {
             MetricsFeature feature = featuresRegistry.get(featureName);
@@ -140,7 +151,7 @@
          *
          * @param newName name of the Feature
          */
-        private Feature(final String newName) {
+        Feature(final String newName) {
             name = newName;
         }
 
@@ -151,12 +162,6 @@
     }
 
     /**
-     * Registry to hold the Components defined in the system.
-     */
-    private static ConcurrentMap<String, MetricsComponent> componentsRegistry =
-            new ConcurrentHashMap<>();
-
-    /**
      * Registers a component.
      *
      * @param name name of the Component to register
@@ -175,11 +180,6 @@
     }
 
     /**
-     * Registry for the Metrics objects created in the system.
-     */
-    private static final MetricRegistry METRICS_REGISTRY = new MetricRegistry();
-
-    /**
      * Generates a name for a Metric from its component and feature.
      *
      * @param component component the metric is defined in
diff --git a/src/main/java/net/onrc/onos/core/metrics/web/MetricsObjectResource.java b/src/main/java/net/onrc/onos/core/metrics/web/MetricsObjectResource.java
index 64db953..bf4e4c2 100644
--- a/src/main/java/net/onrc/onos/core/metrics/web/MetricsObjectResource.java
+++ b/src/main/java/net/onrc/onos/core/metrics/web/MetricsObjectResource.java
@@ -19,6 +19,12 @@
 @SuppressWarnings("rawtypes")
 public class MetricsObjectResource {
 
+    private List<TimerObjectResource> timers;
+    private List<GaugeObjectResource> gauges;
+    private List<CounterObjectResource> counters;
+    private List<MeterObjectResource> meters;
+    private List<HistogramObjectResource> histograms;
+
     /**
      * Base Metric object that all metrics inherit from.  Defines common
      * attributes.
@@ -185,13 +191,6 @@
         }
     }
 
-
-    private List<TimerObjectResource> timers;
-    private List<GaugeObjectResource> gauges;
-    private List<CounterObjectResource> counters;
-    private List<MeterObjectResource> meters;
-    private List<HistogramObjectResource> histograms;
-
     /**
      * Gets the list of Gauge objects.
      *
diff --git a/src/main/java/net/onrc/onos/core/metrics/web/MetricsResource.java b/src/main/java/net/onrc/onos/core/metrics/web/MetricsResource.java
index 89746e3..59c450c 100644
--- a/src/main/java/net/onrc/onos/core/metrics/web/MetricsResource.java
+++ b/src/main/java/net/onrc/onos/core/metrics/web/MetricsResource.java
@@ -17,6 +17,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * REST APIs for Metrics objects.
@@ -27,7 +28,7 @@
      * Metric filter to allow selecting metrics by name.
      */
     private static class MetricNameFilter implements MetricFilter {
-        final HashSet<String> names;
+        private final Set<String> names;
 
         /**
          * Hide default constructor.
diff --git a/src/main/java/net/onrc/onos/core/metrics/web/MetricsWebRoutable.java b/src/main/java/net/onrc/onos/core/metrics/web/MetricsWebRoutable.java
index d79e659..3a3f493 100644
--- a/src/main/java/net/onrc/onos/core/metrics/web/MetricsWebRoutable.java
+++ b/src/main/java/net/onrc/onos/core/metrics/web/MetricsWebRoutable.java
@@ -11,6 +11,9 @@
 public class MetricsWebRoutable implements RestletRoutable {
     /**
      * Creates the Restlet router and binds to the proper resources.
+     *
+     * @param context Context to use for the restlet
+     * @return the router for Metrics REST calls
      */
     @Override
     public Restlet getRestlet(Context context) {
@@ -22,7 +25,9 @@
 
 
     /**
-     * Sets the base path for the Metrics.
+     * Defines the base path for the Metrics.
+     *
+     * @return base path for Metrics REST APIs
      */
     @Override
     public String basePath() {
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestMetrics.java b/src/test/java/net/onrc/onos/api/rest/TestRestMetrics.java
index d0f6b1e..34f6e0f 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestMetrics.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestMetrics.java
@@ -96,6 +96,9 @@
         }
     }
 
+    /**
+     * Tick time of the mock clock, in milliseconds.
+     */
     public static final int MOCK_CLOCK_MILISECONDS_PER_TICK = 50;
 
     /**
@@ -104,7 +107,7 @@
      * MOCK_CLOCK_MILISECONDS_PER_TICK which is currently defined for 50
      * millisecond ticks.
      */
-    protected final Clock mockClock = new Clock() {
+    private final Clock mockClock = new Clock() {
         private long currentTime = 0;
 
         @Override
@@ -116,4 +119,13 @@
             return currentTime;
         }
     };
+
+    /**
+     * Fetches a mock clock that can be used for Timers and Meters.
+     *
+     * @return Mock clock base on 50 msec ticks
+     */
+    public Clock getMockClock() {
+        return mockClock;
+    }
 }
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsCounters.java b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsCounters.java
index 148fd85..3ae9059 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsCounters.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsCounters.java
@@ -118,7 +118,7 @@
     /**
      * Test the REST APIs for Metrics Counter objects.
      *
-     * @throws JSONException
+     * @throws JSONException if JSON processing fails
      */
     @Test
     public void testCounters() throws JSONException {
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsGauges.java b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsGauges.java
index b6c5cab..95c1aff 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsGauges.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsGauges.java
@@ -93,6 +93,9 @@
                         }
                     };
 
+    /**
+     * Registers the test Gauge objects.
+     */
     private void registerGauges() {
         OnosMetrics.registerMetric(COMPONENT,
                                    FEATURE,
@@ -141,7 +144,7 @@
      * @throws JSONException if any JSON operation fails
      */
     @Test
-    public void testGauges() throws Exception {
+    public void testGauges() throws JSONException {
         registerGauges();
 
         //  Read the metrics from the REST API for the test data
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsMeters.java b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsMeters.java
index da046fd..a14acef 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsMeters.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsMeters.java
@@ -73,9 +73,9 @@
             OnosMetrics.generateName(COMPONENT, FEATURE, METER3_NAME);
     private static final int METER3_ITERATIONS = 100;
 
-    private final Meter meter1 = new Meter(mockClock);
-    private final Meter meter2 = new Meter(mockClock);
-    private final Meter meter3 = new Meter(mockClock);
+    private final Meter meter1 = new Meter(getMockClock());
+    private final Meter meter2 = new Meter(getMockClock());
+    private final Meter meter3 = new Meter(getMockClock());
 
     /**
      * Fill in test data for a given Meter.
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsTimers.java b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsTimers.java
index dd8cf8c..6d16bf7 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestMetricsTimers.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestMetricsTimers.java
@@ -69,8 +69,8 @@
     private static final int RESERVOIR_SIZE = 100;
     private Reservoir reservoir = new SlidingWindowReservoir(RESERVOIR_SIZE);
 
-    private final Timer timer1 = new Timer(reservoir, mockClock);
-    private final Timer timer2 = new Timer(reservoir, mockClock);
+    private final Timer timer1 = new Timer(reservoir, getMockClock());
+    private final Timer timer2 = new Timer(reservoir, getMockClock());
 
     /**
      * Fill in test data in the Timer objects.
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestTopologyGet.java b/src/test/java/net/onrc/onos/api/rest/TestRestTopologyGet.java
index bf8d831..4eba584 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestTopologyGet.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestTopologyGet.java
@@ -146,9 +146,11 @@
      * Test that the GET of all Topology REST call returns the proper result.
      * The call to get all Topology should return 3 items (switches, links,
      * and hosts), an HTTP status of OK, and the proper topology data.
+     *
+     * @throws JSONException if JSON processing fails
      */
     @Test
-    public void testFetchOfAllTopology() throws Exception {
+    public void testFetchOfAllTopology() throws JSONException {
         final ClientResource client = new ClientResource(getBaseRestTopologyUrl());
         final JSONObject topology = getJSONObject(client);
 
@@ -174,9 +176,11 @@
     /**
      * Test that the GET of all switches REST call returns the proper result.
      * The call to get all switches should return the correct switch data.
+     *
+     * @throws JSONException if JSON processing fails
      */
     @Test
-    public void testFetchOfAllSwitches() throws Exception {
+    public void testFetchOfAllSwitches() throws JSONException {
         final ClientResource client = new ClientResource(getBaseRestTopologyUrl() + "/switches");
         final JSONArray switches = getJSONArray(client);
 
@@ -189,9 +193,11 @@
     /**
      * Test that the GET of all links REST call returns the proper result.
      * The call to get all links should return the proper link data.
+     *
+     * @throws JSONException if JSON processing fails
      */
     @Test
-    public void testFetchOfAllLinks() throws Exception {
+    public void testFetchOfAllLinks() throws JSONException {
         final ClientResource client = new ClientResource(getBaseRestTopologyUrl() + "/links");
         final JSONArray links = getJSONArray(client);
 
@@ -204,9 +210,11 @@
     /**
      * Test that the GET of all hosts REST call returns the proper result.
      * The call to get all hosts should return no hosts.
+     *
+     * @throws JSONException if JSON processing fails
      */
     @Test
-    public void testFetchOfAllHosts() throws Exception {
+    public void testFetchOfAllHosts() throws JSONException {
         final ClientResource client = new ClientResource(getBaseRestTopologyUrl() + "/hosts");
         final JSONArray hosts = getJSONArray(client);