Fix some checkstyle and PMD errors in the topology module.

Change-Id: Icf037cefdff18256f1234ed2b6eac761d29af7ac
diff --git a/conf/pmd/onos_ruleset.xml b/conf/pmd/onos_ruleset.xml
index 1a1fae0..7c862a3 100644
--- a/conf/pmd/onos_ruleset.xml
+++ b/conf/pmd/onos_ruleset.xml
@@ -35,6 +35,7 @@
     <rule ref="rulesets/java/braces.xml"/>
     <rule ref="rulesets/java/naming.xml">
       <exclude name="AvoidInstantiatingObjectsInLoops" />
+      <exclude name="ShortClassName" />
       <exclude name="ShortMethodName" />
       <exclude name="ShortVariable" />
       <exclude name="LongVariable" />
diff --git a/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java b/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
index ff3ee8c..6843fa9 100644
--- a/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
+++ b/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
@@ -123,7 +123,6 @@
 
         final Dpid dpid = new Dpid(sw.getId());
         final PortNumber portNum = new PortNumber(pi.getInPort());
-        Long mac = eth.getSourceMAC().toLong();
 
         Host srcHost =
                 getSourceHostFromPacket(eth, dpid.value(), portNum.value());
@@ -149,6 +148,7 @@
             topology.releaseReadLock();
         }
 
+        Long mac = eth.getSourceMAC().toLong();
         addHost(mac, srcHost);
 
         if (log.isTraceEnabled()) {
@@ -285,7 +285,8 @@
                         switchPort.getDpid().value(),
                         switchPort.getNumber().value(),
                         new Date(host.getLastSeenTime()));
-                break;
+                // FIXME: remove NOPMD flag after multiple attachment points are implemented
+                break; // NOPMD
             }
         } finally {
             topology.releaseReadLock();
diff --git a/src/main/java/net/onrc/onos/core/topology/HostEvent.java b/src/main/java/net/onrc/onos/core/topology/HostEvent.java
index 8747079..4c8f78d 100644
--- a/src/main/java/net/onrc/onos/core/topology/HostEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/HostEvent.java
@@ -132,12 +132,13 @@
         if (getClass() != obj.getClass()) {
             return false;
         }
-        HostEvent other = (HostEvent) obj;
 
         if (!super.equals(obj)) {
             return false;
         }
 
+        HostEvent other = (HostEvent) obj;
+
         // XXX lastSeenTime excluded from Equality condition, is it OK?
         return Objects.equals(mac, other.mac) &&
                 Objects.equals(this.attachmentPoints, other.attachmentPoints);
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
index 9d9b573..cf61017 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
@@ -60,7 +60,7 @@
 
     /**
      * Check if all events contained are equal.
-     * @param object.
+     * @param obj.
      */
     @Override
     public boolean equals(Object obj) {
@@ -128,6 +128,6 @@
         if (hostEvent != null) {
             return hostEvent.getID();
         }
-        return null;
+        throw new IllegalStateException("Invalid TopologyEvent ID");
     }
 }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostEventSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostEventSerializer.java
index eefb4eb..d5a98f0 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostEventSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostEventSerializer.java
@@ -10,8 +10,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes HostEvents as JSON.
+ */
 public class HostEventSerializer extends SerializerBase<HostEvent> {
 
+    /**
+     * Constructs a HostEvent Serializer.
+     */
     public HostEventSerializer() {
         super(HostEvent.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
index c706f26..19425e5 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
@@ -10,8 +10,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes Host objects as JSON.
+ */
 public class HostSerializer extends SerializerBase<Host> {
 
+    /**
+     * Constructs a Host serializer.
+     */
     public HostSerializer() {
         super(Host.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
index 7b06a21..10b29ea 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
@@ -10,8 +10,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes a Link object as JSON.
+ */
 public class LinkSerializer extends SerializerBase<Link> {
 
+    /**
+     * Constructs a Link serializer.
+     */
     public LinkSerializer() {
         super(Link.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/PortEventSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/PortEventSerializer.java
index db22b2d..60c984d 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/PortEventSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/PortEventSerializer.java
@@ -9,8 +9,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes a PortEvent object as JSON.
+ */
 public class PortEventSerializer extends SerializerBase<PortEvent> {
 
+    /**
+     * Constructs a PortEvent serializer.
+     */
     public PortEventSerializer() {
         super(PortEvent.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/PortSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/PortSerializer.java
index 628a923..ff08f5b 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/PortSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/PortSerializer.java
@@ -10,8 +10,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes a Port object as JSON.
+ */
 public class PortSerializer extends SerializerBase<Port> {
 
+    /**
+     * Constructs a Port serializer.
+     */
     public PortSerializer() {
         super(Port.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchEventSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchEventSerializer.java
index c4e1826..78e3536 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchEventSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchEventSerializer.java
@@ -9,8 +9,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes a SwitchEvent as JSON.
+ */
 public class SwitchEventSerializer extends SerializerBase<SwitchEvent> {
 
+    /**
+     * Constructs a SwitchEvent serializer.
+     */
     public SwitchEventSerializer() {
         super(SwitchEvent.class);
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchSerializer.java
index 8542641..69a5cac 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/SwitchSerializer.java
@@ -11,8 +11,14 @@
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
+/**
+ * Serializes a Switch object as JSON.
+ */
 public class SwitchSerializer extends SerializerBase<Switch> {
 
+    /**
+     * Constructs a Switch object serializer.
+     */
     public SwitchSerializer() {
         super(Switch.class);
     }