Enable checkstyle check for blocks without braces.

Enable the checkstyle rule to check for block statements
without curly braces and fix any violations it finds.

Change-Id: Id4c58cea26f0d9ce7ed78643a4943c042886a12d
diff --git a/src/main/java/net/onrc/onos/core/topology/LinkEvent.java b/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
index bf81f34..6f328f0 100644
--- a/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
@@ -78,23 +78,30 @@
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         LinkEvent other = (LinkEvent) obj;
         if (dst == null) {
-            if (other.dst != null)
+            if (other.dst != null) {
                 return false;
-        } else if (!dst.equals(other.dst))
+            }
+        } else if (!dst.equals(other.dst)) {
             return false;
+        }
         if (src == null) {
-            if (other.src != null)
+            if (other.src != null) {
                 return false;
-        } else if (!src.equals(other.src))
+            }
+        } else if (!src.equals(other.src)) {
             return false;
+        }
         return true;
     }
 }
diff --git a/src/main/java/net/onrc/onos/core/topology/NetworkGraphImpl.java b/src/main/java/net/onrc/onos/core/topology/NetworkGraphImpl.java
index a60e390..d28e8bb 100644
--- a/src/main/java/net/onrc/onos/core/topology/NetworkGraphImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/NetworkGraphImpl.java
@@ -71,8 +71,9 @@
     @Override
     public Link getLink(Long dpid, Long number) {
         Port srcPort = getPort(dpid, number);
-        if (srcPort == null)
+        if (srcPort == null) {
             return null;
+        }
         return srcPort.getOutgoingLink();
     }
 
@@ -80,12 +81,15 @@
     public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid,
                         Long dstNumber) {
         Link link = getLink(srcDpid, srcNumber);
-        if (link == null)
+        if (link == null) {
             return null;
-        if (!link.getDstSwitch().getDpid().equals(dstDpid))
+        }
+        if (!link.getDstSwitch().getDpid().equals(dstDpid)) {
             return null;
-        if (!link.getDstPort().getNumber().equals(dstNumber))
+        }
+        if (!link.getDstPort().getNumber().equals(dstNumber)) {
             return null;
+        }
         return link;
     }
 
@@ -134,8 +138,9 @@
             Set<Device> devices = addr2Device.get(ipAddr);
             if (devices != null) {
                 devices.remove(device);
-                if (devices.isEmpty())
+                if (devices.isEmpty()) {
                     addr2Device.remove(ipAddr);
+                }
             }
         }
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/Path.java b/src/main/java/net/onrc/onos/core/topology/Path.java
index 9c5118d..a089248 100644
--- a/src/main/java/net/onrc/onos/core/topology/Path.java
+++ b/src/main/java/net/onrc/onos/core/topology/Path.java
@@ -17,8 +17,9 @@
         Iterator<LinkEvent> i = this.iterator();
         while (i.hasNext()) {
             builder.append(i.next().toString());
-            if (i.hasNext())
+            if (i.hasNext()) {
                 builder.append(", ");
+            }
         }
         return builder.toString();
     }
diff --git a/src/main/java/net/onrc/onos/core/topology/PortEvent.java b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
index 2a18c08..fdf8f06 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
@@ -51,23 +51,30 @@
 
         @Override
         public boolean equals(Object obj) {
-            if (this == obj)
+            if (this == obj) {
                 return true;
-            if (obj == null)
+            }
+            if (obj == null) {
                 return false;
-            if (getClass() != obj.getClass())
+            }
+            if (getClass() != obj.getClass()) {
                 return false;
+            }
             SwitchPort other = (SwitchPort) obj;
             if (dpid == null) {
-                if (other.dpid != null)
+                if (other.dpid != null) {
                     return false;
-            } else if (!dpid.equals(other.dpid))
+                }
+            } else if (!dpid.equals(other.dpid)) {
                 return false;
+            }
             if (number == null) {
-                if (other.number != null)
+                if (other.number != null) {
                     return false;
-            } else if (!number.equals(other.number))
+                }
+            } else if (!number.equals(other.number)) {
                 return false;
+            }
             return true;
         }
     }
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 4f3dd20..85ebe03 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
@@ -62,14 +62,18 @@
      */
     @Override
     public String toString() {
-        if (switchEvent != null)
+        if (switchEvent != null) {
             return switchEvent.toString();
-        if (portEvent != null)
+        }
+        if (portEvent != null) {
             return portEvent.toString();
-        if (linkEvent != null)
+        }
+        if (linkEvent != null) {
             return linkEvent.toString();
-        if (deviceEvent != null)
+        }
+        if (deviceEvent != null) {
             return deviceEvent.toString();
+        }
         return "[Empty TopologyEvent]";
     }
 
@@ -79,14 +83,18 @@
      * @return the Topology event ID.
      */
     public byte[] getID() {
-        if (switchEvent != null)
+        if (switchEvent != null) {
             return switchEvent.getID();
-        if (portEvent != null)
+        }
+        if (portEvent != null) {
             return portEvent.getID();
-        if (linkEvent != null)
+        }
+        if (linkEvent != null) {
             return linkEvent.getID();
-        if (deviceEvent != null)
+        }
+        if (deviceEvent != null) {
             return deviceEvent.getID();
+        }
         return null;
     }
 }
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 d915042..580e785 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -278,26 +278,34 @@
                 // Apply the "add" events in the proper order:
                 //   switch, port, link, device
                 //
-                for (SwitchEvent switchEvent : addedSwitchEvents.values())
+                for (SwitchEvent switchEvent : addedSwitchEvents.values()) {
                     addSwitch(switchEvent);
-                for (PortEvent portEvent : addedPortEvents.values())
+                }
+                for (PortEvent portEvent : addedPortEvents.values()) {
                     addPort(portEvent);
-                for (LinkEvent linkEvent : addedLinkEvents.values())
+                }
+                for (LinkEvent linkEvent : addedLinkEvents.values()) {
                     addLink(linkEvent);
-                for (DeviceEvent deviceEvent : addedDeviceEvents.values())
+                }
+                for (DeviceEvent deviceEvent : addedDeviceEvents.values()) {
                     addDevice(deviceEvent);
+                }
                 //
                 // Apply the "remove" events in the reverse order:
                 //   device, link, port, switch
                 //
-                for (DeviceEvent deviceEvent : removedDeviceEvents.values())
+                for (DeviceEvent deviceEvent : removedDeviceEvents.values()) {
                     removeDevice(deviceEvent);
-                for (LinkEvent linkEvent : removedLinkEvents.values())
+                }
+                for (LinkEvent linkEvent : removedLinkEvents.values()) {
                     removeLink(linkEvent);
-                for (PortEvent portEvent : removedPortEvents.values())
+                }
+                for (PortEvent portEvent : removedPortEvents.values()) {
                     removePort(portEvent);
-                for (SwitchEvent switchEvent : removedSwitchEvents.values())
+                }
+                for (SwitchEvent switchEvent : removedSwitchEvents.values()) {
                     removeSwitch(switchEvent);
+                }
 
                 //
                 // Apply reordered events
@@ -389,22 +397,30 @@
             // Debug statements
             // TODO: Those statements should be removed in the future
             //
-            for (SwitchEvent switchEvent : apiAddedSwitchEvents)
+            for (SwitchEvent switchEvent : apiAddedSwitchEvents) {
                 log.debug("Dispatch Network Graph Event: ADDED {}", switchEvent);
-            for (SwitchEvent switchEvent : apiRemovedSwitchEvents)
+            }
+            for (SwitchEvent switchEvent : apiRemovedSwitchEvents) {
                 log.debug("Dispatch Network Graph Event: REMOVED {}", switchEvent);
-            for (PortEvent portEvent : apiAddedPortEvents)
+            }
+            for (PortEvent portEvent : apiAddedPortEvents) {
                 log.debug("Dispatch Network Graph Event: ADDED {}", portEvent);
-            for (PortEvent portEvent : apiRemovedPortEvents)
+            }
+            for (PortEvent portEvent : apiRemovedPortEvents) {
                 log.debug("Dispatch Network Graph Event: REMOVED {}", portEvent);
-            for (LinkEvent linkEvent : apiAddedLinkEvents)
+            }
+            for (LinkEvent linkEvent : apiAddedLinkEvents) {
                 log.debug("Dispatch Network Graph Event: ADDED {}", linkEvent);
-            for (LinkEvent linkEvent : apiRemovedLinkEvents)
+            }
+            for (LinkEvent linkEvent : apiRemovedLinkEvents) {
                 log.debug("Dispatch Network Graph Event: REMOVED {}", linkEvent);
-            for (DeviceEvent deviceEvent : apiAddedDeviceEvents)
+            }
+            for (DeviceEvent deviceEvent : apiAddedDeviceEvents) {
                 log.debug("Dispatch Network Graph Event: ADDED {}", deviceEvent);
-            for (DeviceEvent deviceEvent : apiRemovedDeviceEvents)
+            }
+            for (DeviceEvent deviceEvent : apiRemovedDeviceEvents) {
                 log.debug("Dispatch Network Graph Event: REMOVED {}", deviceEvent);
+            }
         }
 
         // Deliver the events
@@ -441,8 +457,9 @@
      */
     private void applyReorderedEvents(boolean hasAddedSwitchEvents,
                                       boolean hasAddedPortEvents) {
-        if (!(hasAddedSwitchEvents || hasAddedPortEvents))
+        if (!(hasAddedSwitchEvents || hasAddedPortEvents)) {
             return;        // Nothing to do
+        }
 
         //
         // Try to apply the reordered events.
@@ -460,8 +477,9 @@
         if (hasAddedSwitchEvents) {
             Map<ByteBuffer, PortEvent> portEvents = reorderedAddedPortEvents;
             reorderedAddedPortEvents = new HashMap<>();
-            for (PortEvent portEvent : portEvents.values())
+            for (PortEvent portEvent : portEvents.values()) {
                 addPort(portEvent);
+            }
         }
         //
         // Apply reordered Link and Device Events if Switches or Ports
@@ -469,13 +487,15 @@
         //
         Map<ByteBuffer, LinkEvent> linkEvents = reorderedAddedLinkEvents;
         reorderedAddedLinkEvents = new HashMap<>();
-        for (LinkEvent linkEvent : linkEvents.values())
+        for (LinkEvent linkEvent : linkEvents.values()) {
             addLink(linkEvent);
+        }
         //
         Map<ByteBuffer, DeviceEvent> deviceEvents = reorderedAddedDeviceEvents;
         reorderedAddedDeviceEvents = new HashMap<>();
-        for (DeviceEvent deviceEvent : deviceEvents.values())
+        for (DeviceEvent deviceEvent : deviceEvents.values()) {
             addDevice(deviceEvent);
+        }
     }
 
     /**
@@ -504,8 +524,9 @@
             // Get the old Port Events
             Map<ByteBuffer, PortEvent> oldPortEvents =
                     discoveredAddedPortEvents.get(switchEvent.getDpid());
-            if (oldPortEvents == null)
+            if (oldPortEvents == null) {
                 oldPortEvents = new HashMap<>();
+            }
 
             // Store the new Port Events in the local cache
             Map<ByteBuffer, PortEvent> newPortEvents = new HashMap<>();
@@ -523,13 +544,15 @@
             for (Map.Entry<ByteBuffer, PortEvent> entry : oldPortEvents.entrySet()) {
                 ByteBuffer key = entry.getKey();
                 PortEvent portEvent = entry.getValue();
-                if (!newPortEvents.containsKey(key))
+                if (!newPortEvents.containsKey(key)) {
                     removedPortEvents.add(portEvent);
+                }
             }
 
             // Cleanup old removed ports
-            for (PortEvent portEvent : removedPortEvents)
+            for (PortEvent portEvent : removedPortEvents) {
                 removePortDiscoveryEvent(portEvent);
+            }
         }
     }
 
@@ -543,8 +566,9 @@
         // Get the old Port Events
         Map<ByteBuffer, PortEvent> oldPortEvents =
                 discoveredAddedPortEvents.get(switchEvent.getDpid());
-        if (oldPortEvents == null)
+        if (oldPortEvents == null) {
             oldPortEvents = new HashMap<>();
+        }
 
         if (datastore.deactivateSwitch(switchEvent, oldPortEvents.values())) {
             // Send out notification
@@ -557,8 +581,9 @@
             // because it will attempt to remove the port from the database,
             // and the deactiveSwitch() call above already removed all ports.
             //
-            for (PortEvent portEvent : oldPortEvents.values())
+            for (PortEvent portEvent : oldPortEvents.values()) {
                 eventChannel.removeEntry(portEvent.getID());
+            }
             discoveredAddedPortEvents.remove(switchEvent.getDpid());
 
             // Cleanup for each link
@@ -654,8 +679,9 @@
                         }
                     }
                 }
-                for (DeviceEvent deviceEvent : removedDeviceEvents)
+                for (DeviceEvent deviceEvent : removedDeviceEvents) {
                     removeDeviceDiscoveryEvent(deviceEvent);
+                }
             }
         }
     }
@@ -801,8 +827,9 @@
                     port.getNumber());
             portsToRemove.add(portEvent);
         }
-        for (PortEvent portEvent : portsToRemove)
+        for (PortEvent portEvent : portsToRemove) {
             removePort(portEvent);
+        }
 
         networkGraph.removeSwitch(switchEvent.getDpid());
         apiRemovedSwitchEvents.add(switchEvent);
@@ -865,8 +892,9 @@
             deviceEvent.addAttachmentPoint(switchPort);
             devicesToRemove.add(deviceEvent);
         }
-        for (DeviceEvent deviceEvent : devicesToRemove)
+        for (DeviceEvent deviceEvent : devicesToRemove) {
             removeDevice(deviceEvent);
+        }
 
         //
         // Remove all Links connected to the Port
@@ -876,8 +904,9 @@
         links.add(port.getIncomingLink());
         ArrayList<LinkEvent> linksToRemove = new ArrayList<>();
         for (Link link : links) {
-            if (link == null)
+            if (link == null) {
                 continue;
+            }
             log.debug("Removing Link {} on Port {}", link, portEvent);
             LinkEvent linkEvent = new LinkEvent(link.getSrcSwitch().getDpid(),
                     link.getSrcPort().getNumber(),
@@ -885,8 +914,9 @@
                     link.getDstPort().getNumber());
             linksToRemove.add(linkEvent);
         }
-        for (LinkEvent linkEvent : linksToRemove)
+        for (LinkEvent linkEvent : linksToRemove) {
             removeLink(linkEvent);
+        }
 
         // Remove the Port from the Switch
         SwitchImpl switchImpl = getSwitchImpl(sw);
@@ -940,8 +970,9 @@
                     devicesToRemove.add(deviceEvent);
                 }
             }
-            for (DeviceEvent deviceEvent : devicesToRemove)
+            for (DeviceEvent deviceEvent : devicesToRemove) {
                 removeDevice(deviceEvent);
+            }
         } else {
             // TODO: Update the link attributes
             log.debug("Update link attributes");
@@ -1010,8 +1041,9 @@
         DeviceImpl deviceImpl = getDeviceImpl(device);
 
         // Update the IP addresses
-        for (InetAddress ipAddr : deviceEvent.getIpAddresses())
+        for (InetAddress ipAddr : deviceEvent.getIpAddresses()) {
             deviceImpl.addIpAddress(ipAddr);
+        }
 
         // Process each attachment point
         boolean attachmentFound = false;
diff --git a/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphShortestPathResource.java b/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphShortestPathResource.java
index 6650efc..2fa195b 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphShortestPathResource.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphShortestPathResource.java
@@ -56,8 +56,9 @@
             graph.acquireReadLock();
             Switch srcSwitch = graph.getSwitch(srcDpid.value());
             Switch dstSwitch = graph.getSwitch(dstDpid.value());
-            if ((srcSwitch == null) || (dstSwitch == null))
+            if ((srcSwitch == null) || (dstSwitch == null)) {
                 return "";
+            }
             ConstrainedBFSTree bfsTree = new ConstrainedBFSTree(srcSwitch);
             Path path = bfsTree.getPath(dstSwitch);
             List<Link> links = new LinkedList<>();
@@ -66,8 +67,9 @@
                         linkEvent.getSrc().getNumber(),
                         linkEvent.getDst().getDpid(),
                         linkEvent.getDst().getNumber());
-                if (link == null)
+                if (link == null) {
                     return "";
+                }
                 links.add(link);
             }
             return mapper.writeValueAsString(links);