From 60171f91714302d5e3e5dcbd4d08e3cf94cfde6a Mon Sep 17 00:00:00 2001 From: Alissa Bonas Date: Sun, 8 Sep 2013 19:51:05 +0300 Subject: [PATCH] Add curly braces to if/else statements. (sonar) Change-Id: I34d30294615e98a2a76f8096f4edb50cabab7f24 Signed-off-by: Alissa Bonas --- .../internal/ConnectionManager.java | 15 +++++++---- .../controller/hosttracker/Entity.java | 6 +++-- .../hosttracker/internal/Device.java | 25 +++++++++++-------- .../internal/DeviceManagerImpl.java | 8 +++--- .../controller/switchmanager/Subnet.java | 12 ++++++--- .../java/org/openflow/protocol/OFError.java | 5 ++-- .../action/ActionVendorOutputNextHop.java | 11 ++++---- 7 files changed, 49 insertions(+), 33 deletions(-) diff --git a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java index e2d8f6b03b..da00e9c646 100644 --- a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java +++ b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java @@ -352,16 +352,21 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene String controller = ci.nextArgument(); if (controller == null) { ci.println("Nodes connected to this controller : "); - if (this.getLocalNodes() == null) ci.println("None"); - else ci.println(this.getLocalNodes().toString()); + if (this.getLocalNodes() == null) { + ci.println("None"); + } else { + ci.println(this.getLocalNodes().toString()); + } return; } try { InetAddress address = InetAddress.getByName(controller); ci.println("Nodes connected to controller "+controller); - if (this.getNodes(address) == null) ci.println("None"); - else ci.println(this.getNodes(address).toString()); - return; + if (this.getNodes(address) == null) { + ci.println("None"); + } else { + ci.println(this.getNodes(address).toString()); + } } catch (UnknownHostException e) { e.printStackTrace(); } diff --git a/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java b/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java index 924d0717e9..64f4c7ef1e 100644 --- a/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java +++ b/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java @@ -244,10 +244,12 @@ public class Entity implements Comparable { @Override public int compareTo(Entity o) { int r; - if (port == null) + if (port == null) { r = o.port == null ? 0 : -1; - else if (o.port == null) + } + else if (o.port == null) { r = 1; + } else { // XXX - the node id is only defined as an object rather // than something useful. We're just going to have to diff --git a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java index fb81cddc96..b2180297da 100755 --- a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java +++ b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java @@ -181,7 +181,8 @@ public class Device implements IDevice { * @param newEntity * the entity to add. newEntity must be have the same entity * class as device - * @param if positive indicates the index in the entities array were the new + * @param insertionpoint + * if positive indicates the index in the entities array were the new * entity should be inserted. If negative we will compute the correct * insertion point */ @@ -240,10 +241,11 @@ public class Device implements IDevice { TreeSet vals = new TreeSet(); for (Entity e : entities) { - if (e.getVlan() == null) + if (e.getVlan() == null) { vals.add((short) -1); - else + } else { vals.add(e.getVlan()); + } } return vals.toArray(new Short[vals.size()]); } @@ -313,15 +315,16 @@ public class Device implements IDevice { return false; for (AttachmentPoint ap : apList) { - if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System - .currentTimeMillis()) - expiredAPs.add(ap); + if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System.currentTimeMillis()) { + expiredAPs.add(ap); + } } if (expiredAPs.size() > 0) { apList.removeAll(expiredAPs); return true; - } else + } else { return false; + } } /** @@ -410,7 +413,6 @@ public class Device implements IDevice { * any change to the list of attachment points for the device -- which * indicates a device move. * - * @param sw * @param port * @param lastSeen * @return @@ -525,7 +527,6 @@ public class Device implements IDevice { /** * Delete (sw,port) from the list of list of attachment points and oldAPs. * - * @param sw * @param port * @return */ @@ -703,10 +704,12 @@ public class Device implements IDevice { TreeSet vals = new TreeSet(); for (Entity e : entities) { if (e.getPort().equals(swp.getPort())) { - if (e.getVlan() == null) + if (e.getVlan() == null) { vals.add(VLAN_UNTAGGED); - else + } + else { vals.add(e.getVlan()); + } } } return vals.toArray(new Short[vals.size()]); diff --git a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java index 95d33ceef9..0390907616 100755 --- a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java +++ b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java @@ -385,11 +385,11 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener, long newDomain = 0; boolean newBD = false; - if (oldDomain < newDomain) - return -1; - else if (oldDomain > newDomain) + if (oldDomain < newDomain) { + return -1; + } else if (oldDomain > newDomain) { return 1; - + } // Give preference to OFPP_LOCAL always if (!oldAP.getPort().getType().equals(NodeConnectorIDType.SWSTACK) && newAP.getPort().getType() diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java index 55a7ecb9cd..1deda7c9d0 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java @@ -156,16 +156,20 @@ public class Subnet implements Cloneable, Serializable { } public boolean isSubnetOf(InetAddress ip) { - if (ip == null) + if (ip == null) { return false; + } InetAddress thisPrefix = getPrefixForAddress(this.networkAddress); InetAddress otherPrefix = getPrefixForAddress(ip); - if ((thisPrefix == null) || (otherPrefix == null)) + if ((thisPrefix == null) || (otherPrefix == null)) { return false; - if (thisPrefix.equals(otherPrefix)) + } + if (thisPrefix.equals(otherPrefix)) { return true; - else + } + else { return false; + } } public short getVlan() { diff --git a/third-party/openflowj/src/main/java/org/openflow/protocol/OFError.java b/third-party/openflowj/src/main/java/org/openflow/protocol/OFError.java index 74e39b225c..361a03b926 100644 --- a/third-party/openflowj/src/main/java/org/openflow/protocol/OFError.java +++ b/third-party/openflowj/src/main/java/org/openflow/protocol/OFError.java @@ -128,10 +128,11 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { // OVS apparently sends partial messages in errors // need to be careful of that AND can't use data.limit() as // a packet boundary because there could be more data queued - if (messages.size() > 0) + if (messages.size() > 0) { return messages.get(0); - else + } else { return null; + } } /** diff --git a/third-party/openflowj/src/main/java/org/openflow/protocol/action/ActionVendorOutputNextHop.java b/third-party/openflowj/src/main/java/org/openflow/protocol/action/ActionVendorOutputNextHop.java index d5e5ab0546..f26ca51a79 100644 --- a/third-party/openflowj/src/main/java/org/openflow/protocol/action/ActionVendorOutputNextHop.java +++ b/third-party/openflowj/src/main/java/org/openflow/protocol/action/ActionVendorOutputNextHop.java @@ -74,11 +74,12 @@ import org.openflow.util.HexString; public void setNextHop(InetAddress address) { short actionLen; - if (address instanceof Inet4Address) - actionLen = (short)ONHLength.ONH_LEN_IPV4.getValue(); - else - actionLen = (short)ONHLength.ONH_LEN_IPV6.getValue(); - super.setLength(actionLen); + if (address instanceof Inet4Address) { + actionLen = (short)ONHLength.ONH_LEN_IPV4.getValue(); + } else { + actionLen = (short)ONHLength.ONH_LEN_IPV6.getValue(); + } + super.setLength(actionLen); this.address = address; } public InetAddress getNextHop() { -- 2.36.6