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/conf/checkstyle/sun_checks.xml b/conf/checkstyle/sun_checks.xml
index aa19cec..baf8019 100644
--- a/conf/checkstyle/sun_checks.xml
+++ b/conf/checkstyle/sun_checks.xml
@@ -201,11 +201,7 @@
</module>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
-
- <module name="NeedBraces">
- <property name="severity" value="warning"/>
- </module>
-
+ <module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
diff --git a/src/main/java/net/onrc/onos/apps/bgproute/Ptree.java b/src/main/java/net/onrc/onos/apps/bgproute/Ptree.java
index 7f9a009..8159b57 100644
--- a/src/main/java/net/onrc/onos/apps/bgproute/Ptree.java
+++ b/src/main/java/net/onrc/onos/apps/bgproute/Ptree.java
@@ -112,7 +112,7 @@
PtreeNode node = top;
PtreeNode matched = null;
- if (node != null)
+ if (node != null) {
while (node != null
&& node.keyBits <= key_bits
@@ -125,6 +125,7 @@
node = node.left;
}
}
+ }
if (matched != null) {
return addReference(matched);
@@ -273,11 +274,13 @@
PtreeNode add = new PtreeNode(null, commonLen, maxKeyOctets);
int j;
- for (j = 0; j < i; j++)
+ for (j = 0; j < i; j++) {
add.key[j] = node.key[j];
+ }
- if (boundary != 0)
+ if (boundary != 0) {
add.key[j] = (byte) (node.key[j] & maskBits[add.keyBits % 8]);
+ }
return add;
}
diff --git a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
index 15aed60..d3db080 100644
--- a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
+++ b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
@@ -557,11 +557,13 @@
for (Entry<String, IntentState> entry : value.entrySet()) {
log.debug("path intent key {}, value {}", entry.getKey(), entry.getValue());
PathIntent pathIntent = (PathIntent) intentMap.getIntent(entry.getKey());
- if (pathIntent == null)
+ if (pathIntent == null) {
continue;
+ }
- if (!(pathIntent.getParentIntent() instanceof ShortestPathIntent))
+ if (!(pathIntent.getParentIntent() instanceof ShortestPathIntent)) {
continue;
+ }
IntentState state = entry.getValue();
switch (state) {
diff --git a/src/main/java/net/onrc/onos/core/datagrid/web/GetNGFlowsSummaryResource.java b/src/main/java/net/onrc/onos/core/datagrid/web/GetNGFlowsSummaryResource.java
index 291f82d..37a2346 100644
--- a/src/main/java/net/onrc/onos/core/datagrid/web/GetNGFlowsSummaryResource.java
+++ b/src/main/java/net/onrc/onos/core/datagrid/web/GetNGFlowsSummaryResource.java
@@ -52,16 +52,19 @@
IntentMap intentMap = pathRuntime.getPathIntents();
for (Intent parentIntent : parentIntentMap.getAllIntents()) {
// Get only installed Shortest Paths
- if (parentIntent.getState() != IntentState.INST_ACK)
+ if (parentIntent.getState() != IntentState.INST_ACK) {
continue;
- if (!(parentIntent instanceof ShortestPathIntent))
+ }
+ if (!(parentIntent instanceof ShortestPathIntent)) {
continue;
+ }
ShortestPathIntent spIntent = (ShortestPathIntent) parentIntent;
// Get the Path Intent
Intent intent = intentMap.getIntent(spIntent.getPathIntentId());
- if (!(intent instanceof PathIntent))
+ if (!(intent instanceof PathIntent)) {
continue;
+ }
PathIntent pathIntent = (PathIntent) intent;
// Decode the Shortest Path ID
@@ -107,8 +110,9 @@
}
// Prepare the return result
- for (FlowPath flowPath : sortedFlowPaths.values())
+ for (FlowPath flowPath : sortedFlowPaths.values()) {
result.add(flowPath);
+ }
return result;
}
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
index adac787..09dea03 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
@@ -149,8 +149,9 @@
public void setLastSeenTimestamp(Date lastSeenTimestamp) {
if (activeSince == null ||
(activeSince.getTime() + ACTIVITY_TIMEOUT) <
- lastSeenTimestamp.getTime())
+ lastSeenTimestamp.getTime()) {
this.activeSince = lastSeenTimestamp;
+ }
this.lastSeenTimestamp = lastSeenTimestamp;
}
@@ -164,7 +165,9 @@
@Override
public int hashCode() {
- if (hashCode != 0) return hashCode;
+ if (hashCode != 0) {
+ return hashCode;
+ }
final int prime = 31;
hashCode = 1;
hashCode = prime * hashCode
@@ -178,22 +181,46 @@
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
OnosDevice other = (OnosDevice) obj;
- if (hashCode() != other.hashCode()) return false;
+ if (hashCode() != other.hashCode()) {
+ return false;
+ }
if (ipv4Address == null) {
- if (other.ipv4Address != null) return false;
- } else if (!ipv4Address.equals(other.ipv4Address)) return false;
+ if (other.ipv4Address != null) {
+ return false;
+ }
+ } else if (!ipv4Address.equals(other.ipv4Address)) {
+ return false;
+ }
if (macAddress == null) {
- if (other.macAddress != null) return false;
- } else if (!macAddress.equals(other.macAddress)) return false;
- if (switchDPID != other.switchDPID) return false;
- if (switchPort != other.switchPort) return false;
+ if (other.macAddress != null) {
+ return false;
+ }
+ } else if (!macAddress.equals(other.macAddress)) {
+ return false;
+ }
+ if (switchDPID != other.switchDPID) {
+ return false;
+ }
+ if (switchPort != other.switchPort) {
+ return false;
+ }
if (vlan == null) {
- if (other.vlan != null) return false;
- } else if (!vlan.equals(other.vlan)) return false;
+ if (other.vlan != null) {
+ return false;
+ }
+ } else if (!vlan.equals(other.vlan)) {
+ return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
index a724caa..231c1a0 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
@@ -251,8 +251,9 @@
long dlAddr = Ethernet.toLong(dlAddrArr);
// Ignore broadcast/multicast source
- if ((dlAddrArr[0] & 0x1) != 0)
+ if ((dlAddrArr[0] & 0x1) != 0) {
return null;
+ }
short vlan = eth.getVlanID();
int nwSrc = getSrcNwAddr(eth, dlAddr);
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 a5fa1aa..8098792 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -268,12 +268,15 @@
@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;
+ }
BarrierInfo other = (BarrierInfo) obj;
return (this.dpid == other.dpid) && (this.xid == other.xid);
@@ -906,8 +909,9 @@
fm.setOutPort(OFPort.OFPP_NONE.getValue());
if ((flowModCommand == OFFlowMod.OFPFC_DELETE)
|| (flowModCommand == OFFlowMod.OFPFC_DELETE_STRICT)) {
- if (actionOutputPort != null)
+ if (actionOutputPort != null) {
fm.setOutPort(actionOutputPort);
+ }
}
//
diff --git a/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java b/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
index c72ef4e..8704988 100644
--- a/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
+++ b/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
@@ -46,7 +46,9 @@
Switch sw = switchQueue.poll();
for (Link link : sw.getOutgoingLinks()) {
Switch reachedSwitch = link.getDstPort().getSwitch();
- if (switchSearched.contains(reachedSwitch)) continue;
+ if (switchSearched.contains(reachedSwitch)) {
+ continue;
+ }
if (intents != null &&
intents.getAvailableBandwidth(link) < bandwidth) {
continue;
diff --git a/src/main/java/net/onrc/onos/core/intent/Intent.java b/src/main/java/net/onrc/onos/core/intent/Intent.java
index a8a06b0..27067b3 100644
--- a/src/main/java/net/onrc/onos/core/intent/Intent.java
+++ b/src/main/java/net/onrc/onos/core/intent/Intent.java
@@ -82,16 +82,20 @@
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if ((obj == null) || (getClass() != obj.getClass()))
+ }
+ if ((obj == null) || (getClass() != obj.getClass())) {
return false;
+ }
Intent other = (Intent) obj;
if (id == null) {
- if (other.id != null)
+ if (other.id != null) {
return false;
- } else if (!id.equals(other.id))
+ }
+ } else if (!id.equals(other.id)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/intent/IntentMap.java b/src/main/java/net/onrc/onos/core/intent/IntentMap.java
index 2124d25..0bba44b 100644
--- a/src/main/java/net/onrc/onos/core/intent/IntentMap.java
+++ b/src/main/java/net/onrc/onos/core/intent/IntentMap.java
@@ -117,21 +117,26 @@
//================================================================================
protected void putIntent(Intent intent) {
- if (intents.containsKey(intent.getId()))
+ if (intents.containsKey(intent.getId())) {
removeIntent(intent.getId());
+ }
intents.put(intent.getId(), intent);
events.add(new ChangedEvent(ChangedEventType.ADDED, intent));
}
protected void removeIntent(String intentId) {
Intent intent = intents.remove(intentId);
- if (intent == null) return;
+ if (intent == null) {
+ return;
+ }
events.add(new ChangedEvent(ChangedEventType.REMOVED, intent));
}
protected void setState(String intentId, IntentState state) {
Intent intent = intents.get(intentId);
- if (intent == null) return;
+ if (intent == null) {
+ return;
+ }
intent.setState(state);
events.add(new ChangedEvent(ChangedEventType.STATE_CHANGED, intent));
}
diff --git a/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java b/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
index ad6b1a5..f97b4c1 100644
--- a/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
+++ b/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
@@ -41,7 +41,9 @@
@Override
protected void putIntent(Intent intent) {
- if (!(intent instanceof PathIntent)) return; // TODO throw exception
+ if (!(intent instanceof PathIntent)) {
+ return; // TODO throw exception
+ }
super.putIntent(intent);
PathIntent pathIntent = (PathIntent) intent;
@@ -96,14 +98,17 @@
* @return
*/
public Double getAvailableBandwidth(Link link) {
- if (link == null) return null;
+ if (link == null) {
+ return null;
+ }
Double bandwidth = link.getCapacity();
LinkEvent linkEvent = new LinkEvent(link);
if (!bandwidth.isInfinite()) {
for (PathIntent intent : getIntentsByLink(linkEvent)) {
Double intentBandwidth = intent.getBandwidth();
- if (intentBandwidth == null || intentBandwidth.isInfinite() || intentBandwidth.isNaN())
+ if (intentBandwidth == null || intentBandwidth.isInfinite() || intentBandwidth.isNaN()) {
continue;
+ }
bandwidth -= intentBandwidth;
}
}
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntime.java b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntime.java
index 0600fe3..5a6d2e9 100644
--- a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntime.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntime.java
@@ -101,9 +101,9 @@
// generate new path-intent ID
String oldPathIntentId = spIntent.getPathIntentId();
String newPathIntentId;
- if (oldPathIntentId == null)
+ if (oldPathIntentId == null) {
newPathIntentId = PathIntent.createFirstId(spIntent.getId());
- else {
+ } else {
newPathIntentId = PathIntent.createNextId(oldPathIntentId);
// Request removal of low-level intent if it exists.
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 ddfaa38..5672c58 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
@@ -95,14 +95,16 @@
// ================================================================================
private void reroutePaths(Collection<Intent> oldPaths) {
- if (oldPaths == null || oldPaths.isEmpty())
+ if (oldPaths == null || oldPaths.isEmpty()) {
return;
+ }
IntentOperationList reroutingOperation = new IntentOperationList();
for (Intent intent : oldPaths) {
PathIntent pathIntent = (PathIntent) intent;
- if (pathIntent.isPathFrozen())
+ if (pathIntent.isPathFrozen()) {
continue;
+ }
if (pathIntent.getState().equals(IntentState.INST_ACK) && // XXX: path intents in flight
!reroutingOperation.contains(pathIntent.getParentIntent())) {
reroutingOperation.add(Operator.ADD, pathIntent.getParentIntent());
@@ -162,8 +164,9 @@
@Override
public IntentOperationList executeIntentOperations(IntentOperationList list) {
- if (list == null || list.size() == 0)
+ if (list == null || list.size() == 0) {
return null;
+ }
PerfLogger p = new PerfLogger("executeIntentOperations_" + list.get(0).operator);
lock.lock(); // TODO optimize locking using smaller steps
@@ -325,18 +328,21 @@
removedLinkEvents.size() > 0 ||
removedPortEvents.size() > 0) {
p.log("begin_getIntentsByLink");
- for (LinkEvent linkEvent : removedLinkEvents)
+ for (LinkEvent linkEvent : removedLinkEvents) {
affectedPaths.addAll(pathIntents.getIntentsByLink(linkEvent));
+ }
p.log("end_getIntentsByLink");
p.log("begin_getIntentsByPort");
- for (PortEvent portEvent : removedPortEvents)
+ for (PortEvent portEvent : removedPortEvents) {
affectedPaths.addAll(pathIntents.getIntentsByPort(portEvent.getDpid(), portEvent.getNumber()));
+ }
p.log("end_getIntentsByPort");
p.log("begin_getIntentsByDpid");
- for (SwitchEvent switchEvent : removedSwitchEvents)
+ for (SwitchEvent switchEvent : removedSwitchEvents) {
affectedPaths.addAll(pathIntents.getIntentsByDpid(switchEvent.getDpid()));
+ }
p.log("end_getIntentsByDpid");
}
p.log("begin_reroutePaths");
@@ -371,13 +377,16 @@
IntentStateList pathIntentStates = new IntentStateList();
for (Entry<String, IntentState> entry : value.entrySet()) {
PathIntent pathIntent = (PathIntent) pathIntents.getIntent(entry.getKey());
- if (pathIntent == null) continue;
+ if (pathIntent == null) {
+ continue;
+ }
Intent parentIntent = pathIntent.getParentIntent();
if (parentIntent == null ||
!(parentIntent instanceof ShortestPathIntent) ||
- !((ShortestPathIntent) parentIntent).getPathIntentId().equals(pathIntent.getId()))
+ !((ShortestPathIntent) parentIntent).getPathIntentId().equals(pathIntent.getId())) {
continue;
+ }
IntentState state = entry.getValue();
switch (state) {
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
index 254cc24..187e8b7 100755
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
@@ -83,21 +83,28 @@
@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;
+ }
Link other = (Link) obj;
- if (dst != other.dst)
+ if (dst != other.dst) {
return false;
- if (dstPort != other.dstPort)
+ }
+ if (dstPort != other.dstPort) {
return false;
- if (src != other.src)
+ }
+ if (src != other.src) {
return false;
- if (srcPort != other.srcPort)
+ }
+ if (srcPort != other.srcPort) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java b/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
index 89e9a19..f757360 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
@@ -126,43 +126,56 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof LinkInfo))
+ }
+ if (!(obj instanceof LinkInfo)) {
return false;
+ }
LinkInfo other = (LinkInfo) obj;
if (firstSeenTime == null) {
- if (other.firstSeenTime != null)
+ if (other.firstSeenTime != null) {
return false;
- } else if (!firstSeenTime.equals(other.firstSeenTime))
+ }
+ } else if (!firstSeenTime.equals(other.firstSeenTime)) {
return false;
+ }
if (lastLldpReceivedTime == null) {
- if (other.lastLldpReceivedTime != null)
+ if (other.lastLldpReceivedTime != null) {
return false;
- } else if (!lastLldpReceivedTime.equals(other.lastLldpReceivedTime))
+ }
+ } else if (!lastLldpReceivedTime.equals(other.lastLldpReceivedTime)) {
return false;
+ }
if (lastBddpReceivedTime == null) {
- if (other.lastBddpReceivedTime != null)
+ if (other.lastBddpReceivedTime != null) {
return false;
- } else if (!lastBddpReceivedTime.equals(other.lastBddpReceivedTime))
+ }
+ } else if (!lastBddpReceivedTime.equals(other.lastBddpReceivedTime)) {
return false;
+ }
if (srcPortState == null) {
- if (other.srcPortState != null)
+ if (other.srcPortState != null) {
return false;
- } else if (!srcPortState.equals(other.srcPortState))
+ }
+ } else if (!srcPortState.equals(other.srcPortState)) {
return false;
+ }
if (dstPortState == null) {
- if (other.dstPortState != null)
+ if (other.dstPortState != null) {
return false;
- } else if (!dstPortState.equals(other.dstPortState))
+ }
+ } else if (!dstPortState.equals(other.dstPortState)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
index 6e5e0c3..224ca3a 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
@@ -69,17 +69,22 @@
@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;
+ }
NodePortTuple other = (NodePortTuple) obj;
- if (nodeId != other.nodeId)
+ if (nodeId != other.nodeId) {
return false;
- if (portId != other.portId)
+ }
+ if (portId != other.portId) {
return false;
+ }
return true;
}
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 7b0892d..2267d06 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
@@ -376,8 +376,9 @@
* @param npt
*/
protected void addToQuarantineQueue(NodePortTuple npt) {
- if (quarantineQueue.contains(npt) == false)
+ if (quarantineQueue.contains(npt) == false) {
quarantineQueue.add(npt);
+ }
}
/**
@@ -401,8 +402,9 @@
// TODO We are not checking if the switch port tuple is already
// in the maintenance list or not. This will be an issue for
// really large number of switch ports in the network.
- if (maintenanceQueue.contains(npt) == false)
+ if (maintenanceQueue.contains(npt) == false) {
maintenanceQueue.add(npt);
+ }
}
/**
@@ -469,18 +471,25 @@
UpdateOperation operation;
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
- if (iofSwitch == null) return;
+ if (iofSwitch == null) {
+ return;
+ }
OFPhysicalPort ofp = iofSwitch.getPort(port);
- if (ofp == null) return;
+ if (ofp == null) {
+ return;
+ }
int srcPortState = ofp.getState();
boolean portUp = ((srcPortState &
OFPortState.OFPPS_STP_MASK.getValue()) !=
OFPortState.OFPPS_STP_BLOCK.getValue());
- if (portUp) operation = UpdateOperation.PORT_UP;
- else operation = UpdateOperation.PORT_DOWN;
+ if (portUp) {
+ operation = UpdateOperation.PORT_UP;
+ } else {
+ operation = UpdateOperation.PORT_DOWN;
+ }
LinkUpdate update = new LinkUpdate(new LDUpdate(sw, port, operation));
@@ -567,8 +576,9 @@
return;
}
- if (port == OFPort.OFPP_LOCAL.getValue())
+ if (port == OFPort.OFPP_LOCAL.getValue()) {
return;
+ }
OFPhysicalPort ofpPort = iofSwitch.getPort(port);
@@ -587,8 +597,9 @@
}
// For fast ports, do not send forward LLDPs or BDDPs.
- if (!isReverse && autoPortFastFeature && isFastPort(sw, port))
+ if (!isReverse && autoPortFastFeature && isFastPort(sw, port)) {
return;
+ }
if (log.isTraceEnabled()) {
log.trace("Sending LLDP packet out of swich: {}, port: {}",
@@ -696,13 +707,17 @@
// Send standard LLDPs
for (long sw : switches) {
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
- if (iofSwitch == null) continue;
+ if (iofSwitch == null) {
+ continue;
+ }
if (iofSwitch.getEnabledPorts() != null) {
for (OFPhysicalPort ofp : iofSwitch.getEnabledPorts()) {
- if (isLinkDiscoverySuppressed(sw, ofp.getPortNumber()))
+ if (isLinkDiscoverySuppressed(sw, ofp.getPortNumber())) {
continue;
- if (autoPortFastFeature && isFastPort(sw, ofp.getPortNumber()))
+ }
+ if (autoPortFastFeature && isFastPort(sw, ofp.getPortNumber())) {
continue;
+ }
// sends forward LLDP only non-fastports.
sendDiscoveryMessage(sw, ofp.getPortNumber(), true, false);
@@ -736,10 +751,12 @@
}
long result = System.nanoTime();
- if (localIPAddress != null)
+ if (localIPAddress != null) {
result = result * prime + IPv4.toIPv4Address(localIPAddress.getHostAddress());
- if (localInterface != null)
+ }
+ if (localInterface != null) {
result = result * prime + localInterface.hashCode();
+ }
// set the first 4 bits to 0.
result = result & (0x0fffffffffffffffL);
@@ -776,12 +793,14 @@
return Command.STOP;
}
- if (isLinkDiscoverySuppressed(sw, pi.getInPort()))
+ if (isLinkDiscoverySuppressed(sw, pi.getInPort())) {
return Command.STOP;
+ }
// If this is a malformed LLDP, or not from us, exit
- if (lldp.getPortId() == null || lldp.getPortId().getLength() != 3)
+ if (lldp.getPortId() == null || lldp.getPortId().getLength() != 3) {
return Command.CONTINUE;
+ }
long myId = ByteBuffer.wrap(controllerTLV.getValue()).getLong();
long otherId = 0;
@@ -809,14 +828,16 @@
}
} else if (lldptlv.getType() == 12 && lldptlv.getLength() == 8) {
otherId = ByteBuffer.wrap(lldptlv.getValue()).getLong();
- if (myId == otherId)
+ if (myId == otherId) {
myLLDP = true;
+ }
} else if (lldptlv.getType() == TLV_DIRECTION_TYPE &&
lldptlv.getLength() == TLV_DIRECTION_LENGTH) {
- if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_FORWARD[0])
+ if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_FORWARD[0]) {
isReverse = false;
- else if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_REVERSE[0])
+ } else if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_REVERSE[0]) {
isReverse = true;
+ }
}
}
@@ -896,10 +917,11 @@
Long firstSeenTime = System.currentTimeMillis();
- if (isStandard)
+ if (isStandard) {
lastLldpTime = System.currentTimeMillis();
- else
+ } else {
lastBddpTime = System.currentTimeMillis();
+ }
LinkInfo newLinkInfo =
new LinkInfo(firstSeenTime, lastLldpTime, lastBddpTime,
@@ -959,12 +981,17 @@
if (eth.getEtherType() == Ethernet.TYPE_BSN) {
BSN bsn = (BSN) eth.getPayload();
- if (bsn == null) return Command.STOP;
- if (bsn.getPayload() == null) return Command.STOP;
+ if (bsn == null) {
+ return Command.STOP;
+ }
+ if (bsn.getPayload() == null) {
+ return Command.STOP;
+ }
// It could be a packet other than BSN LLDP, therefore
// continue with the regular processing.
- if (bsn.getPayload() instanceof LLDP == false)
+ if (bsn.getPayload() instanceof LLDP == false) {
return Command.CONTINUE;
+ }
return handleLldp((LLDP) bsn.getPayload(), sw, pi, false, cntx);
} else if (eth.getEtherType() == Ethernet.TYPE_LLDP) {
return handleLldp((LLDP) eth.getPayload(), sw, pi, true, cntx);
@@ -981,7 +1008,9 @@
// If packet-in is from a quarantine port, stop processing.
NodePortTuple npt = new NodePortTuple(sw, pi.getInPort());
- if (quarantineQueue.contains(npt)) return Command.STOP;
+ if (quarantineQueue.contains(npt)) {
+ return Command.STOP;
+ }
return Command.CONTINUE;
}
@@ -996,7 +1025,9 @@
OFPortState.OFPPS_STP_MASK.getValue()) !=
OFPortState.OFPPS_STP_BLOCK.getValue()));
- if (added) return UpdateOperation.LINK_UPDATED;
+ if (added) {
+ return UpdateOperation.LINK_UPDATED;
+ }
return UpdateOperation.LINK_REMOVED;
}
@@ -1006,8 +1037,11 @@
OFPortState.OFPPS_STP_MASK.getValue()) !=
OFPortState.OFPPS_STP_BLOCK.getValue());
- if (portUp) return UpdateOperation.PORT_UP;
- else return UpdateOperation.PORT_DOWN;
+ if (portUp) {
+ return UpdateOperation.PORT_UP;
+ } else {
+ return UpdateOperation.PORT_DOWN;
+ }
}
protected boolean addOrUpdateLink(Link lt, LinkInfo newInfo) {
@@ -1020,8 +1054,9 @@
// put the new info. if an old info exists, it will be returned.
LinkInfo oldInfo = links.put(lt, newInfo);
if (oldInfo != null &&
- oldInfo.getFirstSeenTime() < newInfo.getFirstSeenTime())
+ oldInfo.getFirstSeenTime() < newInfo.getFirstSeenTime()) {
newInfo.setFirstSeenTime(oldInfo.getFirstSeenTime());
+ }
if (log.isTraceEnabled()) {
log.trace("addOrUpdateLink: {} {}",
@@ -1037,27 +1072,32 @@
if (oldInfo == null) {
// index it by switch source
- if (!switchLinks.containsKey(lt.getSrc()))
+ if (!switchLinks.containsKey(lt.getSrc())) {
switchLinks.put(lt.getSrc(), new HashSet<Link>());
+ }
switchLinks.get(lt.getSrc()).add(lt);
// index it by switch dest
- if (!switchLinks.containsKey(lt.getDst()))
+ if (!switchLinks.containsKey(lt.getDst())) {
switchLinks.put(lt.getDst(), new HashSet<Link>());
+ }
switchLinks.get(lt.getDst()).add(lt);
// index both ends by switch:port
- if (!portLinks.containsKey(srcNpt))
+ if (!portLinks.containsKey(srcNpt)) {
portLinks.put(srcNpt, new HashSet<Link>());
+ }
portLinks.get(srcNpt).add(lt);
- if (!portLinks.containsKey(dstNpt))
+ if (!portLinks.containsKey(dstNpt)) {
portLinks.put(dstNpt, new HashSet<Link>());
+ }
portLinks.get(dstNpt).add(lt);
// Add to portNOFLinks if the unicast valid time is null
- if (newInfo.getUnicastValidTime() == null)
+ if (newInfo.getUnicastValidTime() == null) {
addLinkToBroadcastDomain(lt);
+ }
// ONOS: Distinguish added event separately from updated event
updateOperation = UpdateOperation.LINK_ADDED;
@@ -1108,8 +1148,9 @@
if (newInfo.getSrcPortState().intValue() !=
oldInfo.getSrcPortState().intValue() ||
newInfo.getDstPortState().intValue() !=
- oldInfo.getDstPortState().intValue())
+ oldInfo.getDstPortState().intValue()) {
linkChanged = true;
+ }
if (linkChanged) {
updateOperation = getUpdateOperation(newInfo.getSrcPortState(),
@@ -1166,21 +1207,25 @@
switchLinks.get(lt.getSrc()).remove(lt);
switchLinks.get(lt.getDst()).remove(lt);
if (switchLinks.containsKey(lt.getSrc()) &&
- switchLinks.get(lt.getSrc()).isEmpty())
+ switchLinks.get(lt.getSrc()).isEmpty()) {
this.switchLinks.remove(lt.getSrc());
+ }
if (this.switchLinks.containsKey(lt.getDst()) &&
- this.switchLinks.get(lt.getDst()).isEmpty())
+ this.switchLinks.get(lt.getDst()).isEmpty()) {
this.switchLinks.remove(lt.getDst());
+ }
if (this.portLinks.get(srcNpt) != null) {
this.portLinks.get(srcNpt).remove(lt);
- if (this.portLinks.get(srcNpt).isEmpty())
+ if (this.portLinks.get(srcNpt).isEmpty()) {
this.portLinks.remove(srcNpt);
+ }
}
if (this.portLinks.get(dstNpt) != null) {
this.portLinks.get(dstNpt).remove(lt);
- if (this.portLinks.get(dstNpt).isEmpty())
+ if (this.portLinks.get(dstNpt).isEmpty()) {
this.portLinks.remove(dstNpt);
+ }
}
LinkInfo info = this.links.remove(lt);
@@ -1222,11 +1267,14 @@
protected Command handlePortStatus(long sw, OFPortStatus ps) {
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
- if (iofSwitch == null) return Command.CONTINUE;
+ if (iofSwitch == null) {
+ return Command.CONTINUE;
+ }
// ONOS: If we do not control this switch, then we should not process its port status messages
- if (!registryService.hasControl(iofSwitch.getId()))
+ if (!registryService.hasControl(iofSwitch.getId())) {
return Command.CONTINUE;
+ }
if (log.isTraceEnabled()) {
log.trace("handlePortStatus: Switch {} port #{} reason {}; " +
@@ -1465,8 +1513,9 @@
(info.getUnicastValidTime() + (this.LINK_TIMEOUT * 1000) < curTime)) {
info.setUnicastValidTime(null);
- if (info.getMulticastValidTime() != null)
+ if (info.getMulticastValidTime() != null) {
addLinkToBroadcastDomain(lt);
+ }
// Note that even if mTime becomes null later on,
// the link would be deleted, which would trigger updateClusters().
linkChanged = true;
@@ -1507,12 +1556,15 @@
}
private boolean portEnabled(OFPhysicalPort port) {
- if (port == null)
+ if (port == null) {
return false;
- if ((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0)
+ }
+ if ((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) {
return false;
- if ((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0)
+ }
+ if ((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0) {
return false;
+ }
// Port STP state doesn't work with multiple VLANs, so ignore it for now
// if ((port.getState() & OFPortState.OFPPS_STP_MASK.getValue()) == OFPortState.OFPPS_STP_BLOCK.getValue())
// return false;
@@ -1541,12 +1593,14 @@
srcNpt = new NodePortTuple(lt.getSrc(), lt.getSrcPort());
dstNpt = new NodePortTuple(lt.getDst(), lt.getDstPort());
- if (!portBroadcastDomainLinks.containsKey(srcNpt))
+ if (!portBroadcastDomainLinks.containsKey(srcNpt)) {
portBroadcastDomainLinks.put(srcNpt, new HashSet<Link>());
+ }
portBroadcastDomainLinks.get(srcNpt).add(lt);
- if (!portBroadcastDomainLinks.containsKey(dstNpt))
+ if (!portBroadcastDomainLinks.containsKey(dstNpt)) {
portBroadcastDomainLinks.put(dstNpt, new HashSet<Link>());
+ }
portBroadcastDomainLinks.get(dstNpt).add(lt);
}
@@ -1558,14 +1612,16 @@
if (portBroadcastDomainLinks.containsKey(srcNpt)) {
portBroadcastDomainLinks.get(srcNpt).remove(lt);
- if (portBroadcastDomainLinks.get(srcNpt).isEmpty())
+ if (portBroadcastDomainLinks.get(srcNpt).isEmpty()) {
portBroadcastDomainLinks.remove(srcNpt);
+ }
}
if (portBroadcastDomainLinks.containsKey(dstNpt)) {
portBroadcastDomainLinks.get(dstNpt).remove(lt);
- if (portBroadcastDomainLinks.get(dstNpt).isEmpty())
+ if (portBroadcastDomainLinks.get(dstNpt).isEmpty()) {
portBroadcastDomainLinks.remove(dstNpt);
+ }
}
}
@@ -1736,8 +1792,9 @@
floodlightProvider.addOFMessageListener(OFType.PORT_STATUS, this);
// Register for switch updates
floodlightProvider.addOFSwitchListener(this);
- if (restApi != null)
+ if (restApi != null) {
restApi.addRestletRoutable(new LinkDiscoveryWebRoutable());
+ }
setControllerTLV();
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java b/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
index 0cea4dd..a13116f 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
@@ -24,8 +24,10 @@
linkDiscovery.setAutoPortFastFeature(false);
}
setStatus(Status.SUCCESS_OK, "OK");
- if (linkDiscovery.isAutoPortFastFeature())
+ if (linkDiscovery.isAutoPortFastFeature()) {
return "enabled";
- else return "disabled";
+ } else {
+ return "disabled";
+ }
}
}
diff --git a/src/main/java/net/onrc/onos/core/packet/ARP.java b/src/main/java/net/onrc/onos/core/packet/ARP.java
index ec62d40..ae49c4b 100644
--- a/src/main/java/net/onrc/onos/core/packet/ARP.java
+++ b/src/main/java/net/onrc/onos/core/packet/ARP.java
@@ -266,31 +266,43 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof ARP))
+ }
+ if (!(obj instanceof ARP)) {
return false;
+ }
ARP other = (ARP) obj;
- if (hardwareAddressLength != other.hardwareAddressLength)
+ if (hardwareAddressLength != other.hardwareAddressLength) {
return false;
- if (hardwareType != other.hardwareType)
+ }
+ if (hardwareType != other.hardwareType) {
return false;
- if (opCode != other.opCode)
+ }
+ if (opCode != other.opCode) {
return false;
- if (protocolAddressLength != other.protocolAddressLength)
+ }
+ if (protocolAddressLength != other.protocolAddressLength) {
return false;
- if (protocolType != other.protocolType)
+ }
+ if (protocolType != other.protocolType) {
return false;
- if (!Arrays.equals(senderHardwareAddress, other.senderHardwareAddress))
+ }
+ if (!Arrays.equals(senderHardwareAddress, other.senderHardwareAddress)) {
return false;
- if (!Arrays.equals(senderProtocolAddress, other.senderProtocolAddress))
+ }
+ if (!Arrays.equals(senderProtocolAddress, other.senderProtocolAddress)) {
return false;
- if (!Arrays.equals(targetHardwareAddress, other.targetHardwareAddress))
+ }
+ if (!Arrays.equals(targetHardwareAddress, other.targetHardwareAddress)) {
return false;
- if (!Arrays.equals(targetProtocolAddress, other.targetProtocolAddress))
+ }
+ if (!Arrays.equals(targetProtocolAddress, other.targetProtocolAddress)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/packet/BSN.java b/src/main/java/net/onrc/onos/core/packet/BSN.java
index 0de2bca..654da68 100644
--- a/src/main/java/net/onrc/onos/core/packet/BSN.java
+++ b/src/main/java/net/onrc/onos/core/packet/BSN.java
@@ -85,11 +85,13 @@
bb.putInt(BSN_MAGIC);
bb.putShort(this.type);
bb.putShort(this.version);
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
- if (this.parent != null && this.parent instanceof Ethernet)
+ if (this.parent != null && this.parent instanceof Ethernet) {
((Ethernet) this.parent).setEtherType(Ethernet.TYPE_BSN);
+ }
return data;
}
@@ -147,12 +149,15 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof BSN))
+ }
+ if (!(obj instanceof BSN)) {
return false;
+ }
BSN other = (BSN) obj;
return (type == other.type &&
version == other.version);
@@ -161,10 +166,12 @@
public String toString() {
StringBuffer sb = new StringBuffer("\n");
sb.append("BSN packet");
- if (TYPE_CLASS_MAP.containsKey(this.type))
+ if (TYPE_CLASS_MAP.containsKey(this.type)) {
sb.append(" type: " + TYPE_CLASS_MAP.get(this.type).getCanonicalName());
- else
+ } else {
sb.append(" type: " + this.type);
+ }
+
return sb.toString();
}
diff --git a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java b/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
index c284aca..2f19d49 100644
--- a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
+++ b/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
@@ -115,11 +115,13 @@
bb.put(this.dstMac);
bb.putLong(this.srcSwDpid);
bb.putInt(this.srcPortNo);
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
- if (this.parent != null && this.parent instanceof BSN)
+ if (this.parent != null && this.parent instanceof BSN) {
((BSN) this.parent).setType(BSN.BSN_TYPE_PROBE);
+ }
return data;
}
@@ -163,17 +165,22 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof BSNPROBE))
+ }
+ if (!(obj instanceof BSNPROBE)) {
return false;
+ }
BSNPROBE other = (BSNPROBE) obj;
- if (!Arrays.equals(srcMac, other.srcMac))
+ if (!Arrays.equals(srcMac, other.srcMac)) {
return false;
- if (!Arrays.equals(dstMac, other.dstMac))
+ }
+ if (!Arrays.equals(dstMac, other.dstMac)) {
return false;
+ }
return (sequenceId == other.sequenceId &&
srcSwDpid == other.srcSwDpid &&
srcPortNo == other.srcPortNo
diff --git a/src/main/java/net/onrc/onos/core/packet/BasePacket.java b/src/main/java/net/onrc/onos/core/packet/BasePacket.java
index 3dd6339..780053e 100644
--- a/src/main/java/net/onrc/onos/core/packet/BasePacket.java
+++ b/src/main/java/net/onrc/onos/core/packet/BasePacket.java
@@ -61,8 +61,9 @@
@Override
public void resetChecksum() {
- if (this.parent != null)
+ if (this.parent != null) {
this.parent.resetChecksum();
+ }
}
/* (non-Javadoc)
@@ -81,18 +82,23 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof BasePacket))
+ }
+ if (!(obj instanceof BasePacket)) {
return false;
+ }
BasePacket other = (BasePacket) obj;
if (payload == null) {
- if (other.payload != null)
+ if (other.payload != null) {
return false;
- } else if (!payload.equals(other.payload))
+ }
+ } else if (!payload.equals(other.payload)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/packet/DHCP.java b/src/main/java/net/onrc/onos/core/packet/DHCP.java
index 3d51cf8..aea1ab1 100644
--- a/src/main/java/net/onrc/onos/core/packet/DHCP.java
+++ b/src/main/java/net/onrc/onos/core/packet/DHCP.java
@@ -286,8 +286,9 @@
*/
public DHCPOption getOption(DHCPOptionCode optionCode) {
for (DHCPOption opt : options) {
- if (opt.code == optionCode.value)
+ if (opt.code == optionCode.value) {
return opt;
+ }
}
return null;
}
@@ -368,8 +369,9 @@
}
}
int optionsPadLength = 0;
- if (optionsLength < 60)
+ if (optionsLength < 60) {
optionsPadLength = 60 - optionsLength;
+ }
byte[] data = new byte[240 + optionsLength + optionsPadLength];
ByteBuffer bb = ByteBuffer.wrap(data);
@@ -454,8 +456,9 @@
this.clientHardwareAddress = new byte[hardwareAddressLength];
bb.get(this.clientHardwareAddress);
- for (int i = hardwareAddressLength; i < 16; ++i)
+ for (int i = hardwareAddressLength; i < 16; ++i) {
bb.get();
+ }
this.serverName = readString(bb, 64);
this.bootFileName = readString(bb, 128);
// read the magic cookie
diff --git a/src/main/java/net/onrc/onos/core/packet/DHCPOption.java b/src/main/java/net/onrc/onos/core/packet/DHCPOption.java
index 7c56a34..e2b3c00 100644
--- a/src/main/java/net/onrc/onos/core/packet/DHCPOption.java
+++ b/src/main/java/net/onrc/onos/core/packet/DHCPOption.java
@@ -90,19 +90,25 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof DHCPOption))
+ }
+ if (!(obj instanceof DHCPOption)) {
return false;
+ }
DHCPOption other = (DHCPOption) obj;
- if (code != other.code)
+ if (code != other.code) {
return false;
- if (!Arrays.equals(data, other.data))
+ }
+ if (!Arrays.equals(data, other.data)) {
return false;
- if (length != other.length)
+ }
+ if (length != other.length) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/packet/Data.java b/src/main/java/net/onrc/onos/core/packet/Data.java
index f6f9138..a2e7a79 100644
--- a/src/main/java/net/onrc/onos/core/packet/Data.java
+++ b/src/main/java/net/onrc/onos/core/packet/Data.java
@@ -79,15 +79,19 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof Data))
+ }
+ if (!(obj instanceof Data)) {
return false;
+ }
Data other = (Data) obj;
- if (!Arrays.equals(data, other.data))
+ if (!Arrays.equals(data, other.data)) {
return false;
+ }
return true;
}
}
diff --git a/src/main/java/net/onrc/onos/core/packet/Ethernet.java b/src/main/java/net/onrc/onos/core/packet/Ethernet.java
index fe09bd0..19e7c70 100644
--- a/src/main/java/net/onrc/onos/core/packet/Ethernet.java
+++ b/src/main/java/net/onrc/onos/core/packet/Ethernet.java
@@ -223,8 +223,9 @@
bb.putShort((short) ((priorityCode << 13) | (vlanID & 0x0fff)));
}
bb.putShort(etherType);
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
if (pad) {
Arrays.fill(data, bb.position(), data.length, (byte) 0x0);
}
@@ -233,17 +234,20 @@
@Override
public IPacket deserialize(byte[] data, int offset, int length) {
- if (length <= 0)
+ if (length <= 0) {
return null;
+ }
ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
- if (this.destinationMACAddress == null)
+ if (this.destinationMACAddress == null) {
this.destinationMACAddress = MACAddress.valueOf(new byte[6]);
+ }
byte[] dstAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
bb.get(dstAddr);
this.destinationMACAddress = MACAddress.valueOf(dstAddr);
- if (this.sourceMACAddress == null)
+ if (this.sourceMACAddress == null) {
this.sourceMACAddress = MACAddress.valueOf(new byte[6]);
+ }
byte[] srcAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
bb.get(srcAddr);
this.sourceMACAddress = MACAddress.valueOf(srcAddr);
@@ -283,8 +287,9 @@
*/
public static boolean isMACAddress(String macAddress) {
String[] macBytes = macAddress.split(":");
- if (macBytes.length != 6)
+ if (macBytes.length != 6) {
return false;
+ }
for (int i = 0; i < 6; ++i) {
if (HEXES.indexOf(macBytes[i].toUpperCase().charAt(0)) == -1 ||
HEXES.indexOf(macBytes[i].toUpperCase().charAt(1)) == -1) {
@@ -348,25 +353,34 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof Ethernet))
+ }
+ if (!(obj instanceof Ethernet)) {
return false;
+ }
Ethernet other = (Ethernet) obj;
- if (!destinationMACAddress.equals(other.destinationMACAddress))
+ if (!destinationMACAddress.equals(other.destinationMACAddress)) {
return false;
- if (priorityCode != other.priorityCode)
+ }
+ if (priorityCode != other.priorityCode) {
return false;
- if (vlanID != other.vlanID)
+ }
+ if (vlanID != other.vlanID) {
return false;
- if (etherType != other.etherType)
+ }
+ if (etherType != other.etherType) {
return false;
- if (pad != other.pad)
+ }
+ if (pad != other.pad) {
return false;
- if (!sourceMACAddress.equals(other.sourceMACAddress))
+ }
+ if (!sourceMACAddress.equals(other.sourceMACAddress)) {
return false;
+ }
return true;
}
@@ -380,23 +394,26 @@
IPacket pkt = (IPacket) this.getPayload();
- if (pkt instanceof ARP)
+ if (pkt instanceof ARP) {
sb.append("arp");
- else if (pkt instanceof LLDP)
+ } else if (pkt instanceof LLDP) {
sb.append("lldp");
- else if (pkt instanceof ICMP)
+ } else if (pkt instanceof ICMP) {
sb.append("icmp");
- else if (pkt instanceof IPv4)
+ } else if (pkt instanceof IPv4) {
sb.append("ip");
- else if (pkt instanceof DHCP)
+ } else if (pkt instanceof DHCP) {
sb.append("dhcp");
- else sb.append(this.getEtherType());
+ } else {
+ sb.append(this.getEtherType());
+ }
sb.append("\ndl_vlan: ");
- if (this.getVlanID() == Ethernet.VLAN_UNTAGGED)
+ if (this.getVlanID() == Ethernet.VLAN_UNTAGGED) {
sb.append("untagged");
- else
+ } else {
sb.append(this.getVlanID());
+ }
sb.append("\ndl_vlan_pcp: ");
sb.append(this.getPriorityCode());
sb.append("\ndl_src: ");
@@ -460,7 +477,9 @@
sb.append("\nllc packet");
} else if (pkt instanceof BPDU) {
sb.append("\nbpdu packet");
- } else sb.append("\nunknown packet");
+ } else {
+ sb.append("\nunknwon packet");
+ }
return sb.toString();
}
diff --git a/src/main/java/net/onrc/onos/core/packet/ICMP.java b/src/main/java/net/onrc/onos/core/packet/ICMP.java
index 4b80c94..eb42f96 100644
--- a/src/main/java/net/onrc/onos/core/packet/ICMP.java
+++ b/src/main/java/net/onrc/onos/core/packet/ICMP.java
@@ -95,11 +95,13 @@
bb.put(this.icmpType);
bb.put(this.icmpCode);
bb.putShort(this.checksum);
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
- if (this.parent != null && this.parent instanceof IPv4)
+ if (this.parent != null && this.parent instanceof IPv4) {
((IPv4) this.parent).setProtocol(IPv4.PROTOCOL_ICMP);
+ }
// compute checksum if needed
if (this.checksum == 0) {
@@ -140,19 +142,25 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof ICMP))
+ }
+ if (!(obj instanceof ICMP)) {
return false;
+ }
ICMP other = (ICMP) obj;
- if (icmpType != other.icmpType)
+ if (icmpType != other.icmpType) {
return false;
- if (icmpCode != other.icmpCode)
+ }
+ if (icmpCode != other.icmpCode) {
return false;
- if (checksum != other.checksum)
+ }
+ if (checksum != other.checksum) {
return false;
+ }
return true;
}
diff --git a/src/main/java/net/onrc/onos/core/packet/IPv4.java b/src/main/java/net/onrc/onos/core/packet/IPv4.java
index f1efd7b..8933203 100644
--- a/src/main/java/net/onrc/onos/core/packet/IPv4.java
+++ b/src/main/java/net/onrc/onos/core/packet/IPv4.java
@@ -273,9 +273,10 @@
* @param options the options to set
*/
public IPv4 setOptions(byte[] options) {
- if (options != null && (options.length % 4) > 0)
+ if (options != null && (options.length % 4) > 0) {
throw new IllegalArgumentException(
"Options length must be a multiple of 4");
+ }
this.options = options;
return this;
}
@@ -295,8 +296,9 @@
}
int optionsLength = 0;
- if (this.options != null)
+ if (this.options != null) {
optionsLength = this.options.length / 4;
+ }
this.headerLength = (byte) (5 + optionsLength);
this.totalLength = (short) (this.headerLength * 4 + ((payloadData == null) ? 0
@@ -315,10 +317,12 @@
bb.putShort(this.checksum);
bb.putInt(this.sourceAddress);
bb.putInt(this.destinationAddress);
- if (this.options != null)
+ if (this.options != null) {
bb.put(this.options);
- if (payloadData != null)
+ }
+ if (payloadData != null) {
bb.put(payloadData);
+ }
// compute checksum if needed
if (this.checksum == 0) {
@@ -375,10 +379,11 @@
this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());
this.payload.setParent(this);
- if (this.totalLength != length)
+ if (this.totalLength != length) {
this.isTruncated = true;
- else
+ } else {
this.isTruncated = false;
+ }
return this;
}
@@ -391,13 +396,15 @@
* @return
*/
public static int toIPv4Address(String ipAddress) {
- if (ipAddress == null)
+ if (ipAddress == null) {
throw new IllegalArgumentException("Specified IPv4 address must" +
"contain 4 sets of numerical digits separated by periods");
+ }
String[] octets = ipAddress.split("\\.");
- if (octets.length != 4)
+ if (octets.length != 4) {
throw new IllegalArgumentException("Specified IPv4 address must" +
"contain 4 sets of numerical digits separated by periods");
+ }
int result = 0;
for (int i = 0; i < 4; ++i) {
@@ -435,8 +442,9 @@
for (int i = 0; i < 4; ++i) {
result = (ipAddress >> ((3 - i) * 8)) & 0xff;
sb.append(Integer.valueOf(result).toString());
- if (i != 3)
+ if (i != 3) {
sb.append(".");
+ }
}
return sb.toString();
}
@@ -450,8 +458,9 @@
* @return
*/
public static String fromIPv4AddressCollection(Collection<Integer> ipAddresses) {
- if (ipAddresses == null)
+ if (ipAddresses == null) {
return "null";
+ }
StringBuffer sb = new StringBuffer();
sb.append("[");
for (Integer ip : ipAddresses) {
@@ -471,9 +480,10 @@
*/
public static byte[] toIPv4AddressBytes(String ipAddress) {
String[] octets = ipAddress.split("\\.");
- if (octets.length != 4)
+ if (octets.length != 4) {
throw new IllegalArgumentException("Specified IPv4 address must" +
"contain 4 sets of numerical digits separated by periods");
+ }
byte[] result = new byte[4];
for (int i = 0; i < 4; ++i) {
@@ -525,39 +535,55 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof IPv4))
+ }
+ if (!(obj instanceof IPv4)) {
return false;
+ }
IPv4 other = (IPv4) obj;
- if (checksum != other.checksum)
+ if (checksum != other.checksum) {
return false;
- if (destinationAddress != other.destinationAddress)
+ }
+ if (destinationAddress != other.destinationAddress) {
return false;
- if (diffServ != other.diffServ)
+ }
+ if (diffServ != other.diffServ) {
return false;
- if (flags != other.flags)
+ }
+ if (flags != other.flags) {
return false;
- if (fragmentOffset != other.fragmentOffset)
+ }
+ if (fragmentOffset != other.fragmentOffset) {
return false;
- if (headerLength != other.headerLength)
+ }
+ if (headerLength != other.headerLength) {
return false;
- if (identification != other.identification)
+ }
+ if (identification != other.identification) {
return false;
- if (!Arrays.equals(options, other.options))
+ }
+ if (!Arrays.equals(options, other.options)) {
return false;
- if (protocol != other.protocol)
+ }
+ if (protocol != other.protocol) {
return false;
- if (sourceAddress != other.sourceAddress)
+ }
+ if (sourceAddress != other.sourceAddress) {
return false;
- if (totalLength != other.totalLength)
+ }
+ if (totalLength != other.totalLength) {
return false;
- if (ttl != other.ttl)
+ }
+ if (ttl != other.ttl) {
return false;
- if (version != other.version)
+ }
+ if (version != other.version) {
return false;
+ }
return true;
}
}
diff --git a/src/main/java/net/onrc/onos/core/packet/LLDP.java b/src/main/java/net/onrc/onos/core/packet/LLDP.java
index 0b0f9ec..2cea470 100644
--- a/src/main/java/net/onrc/onos/core/packet/LLDP.java
+++ b/src/main/java/net/onrc/onos/core/packet/LLDP.java
@@ -117,8 +117,9 @@
}
bb.putShort((short) 0); // End of LLDPDU
- if (this.parent != null && this.parent instanceof Ethernet)
+ if (this.parent != null && this.parent instanceof Ethernet) {
((Ethernet) this.parent).setEtherType(ethType);
+ }
return data;
}
@@ -131,8 +132,9 @@
tlv = new LLDPTLV().deserialize(bb);
// if there was a failure to deserialize stop processing TLVs
- if (tlv == null)
+ if (tlv == null) {
break;
+ }
switch (tlv.getType()) {
case 0x0:
// can throw this one away, its just an end delimiter
@@ -174,30 +176,40 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof LLDP))
+ }
+ if (!(obj instanceof LLDP)) {
return false;
+ }
LLDP other = (LLDP) obj;
if (chassisId == null) {
- if (other.chassisId != null)
+ if (other.chassisId != null) {
return false;
- } else if (!chassisId.equals(other.chassisId))
+ }
+ } else if (!chassisId.equals(other.chassisId)) {
return false;
- if (!optionalTLVList.equals(other.optionalTLVList))
+ }
+ if (!optionalTLVList.equals(other.optionalTLVList)) {
return false;
+ }
if (portId == null) {
- if (other.portId != null)
+ if (other.portId != null) {
return false;
- } else if (!portId.equals(other.portId))
+ }
+ } else if (!portId.equals(other.portId)) {
return false;
+ }
if (ttl == null) {
- if (other.ttl != null)
+ if (other.ttl != null) {
return false;
- } else if (!ttl.equals(other.ttl))
+ }
+ } else if (!ttl.equals(other.ttl)) {
return false;
+ }
return true;
}
}
diff --git a/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java b/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
index 7b852e2..e23ce11 100644
--- a/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
+++ b/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
@@ -81,8 +81,9 @@
byte[] data = new byte[2 + this.length];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.putShort(scratch);
- if (this.value != null)
+ if (this.value != null) {
bb.put(this.value);
+ }
return data;
}
@@ -95,8 +96,9 @@
this.value = new byte[this.length];
// if there is an underrun just toss the TLV
- if (bb.remaining() < this.length)
+ if (bb.remaining() < this.length) {
return null;
+ }
bb.get(this.value);
}
return this;
@@ -120,19 +122,25 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof LLDPTLV))
+ }
+ if (!(obj instanceof LLDPTLV)) {
return false;
+ }
LLDPTLV other = (LLDPTLV) obj;
- if (length != other.length)
+ if (length != other.length) {
return false;
- if (type != other.type)
+ }
+ if (type != other.type) {
return false;
- if (!Arrays.equals(value, other.value))
+ }
+ if (!Arrays.equals(value, other.value)) {
return false;
+ }
return true;
}
}
diff --git a/src/main/java/net/onrc/onos/core/packet/TCP.java b/src/main/java/net/onrc/onos/core/packet/TCP.java
index a81db21..f2f49e1 100644
--- a/src/main/java/net/onrc/onos/core/packet/TCP.java
+++ b/src/main/java/net/onrc/onos/core/packet/TCP.java
@@ -167,8 +167,9 @@
*/
public byte[] serialize() {
int length;
- if (dataOffset == 0)
+ if (dataOffset == 0) {
dataOffset = 5; // default header length
+ }
length = dataOffset << 2;
byte[] payloadData = null;
if (payload != null) {
@@ -192,14 +193,17 @@
int padding;
bb.put(options);
padding = (dataOffset << 2) - 20 - options.length;
- for (int i = 0; i < padding; i++)
+ for (int i = 0; i < padding; i++) {
bb.put((byte) 0);
+ }
}
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
- if (this.parent != null && this.parent instanceof IPv4)
+ if (this.parent != null && this.parent instanceof IPv4) {
((IPv4) this.parent).setProtocol(IPv4.PROTOCOL_TCP);
+ }
// compute checksum if needed
if (this.checksum == 0) {
@@ -251,12 +255,15 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof TCP))
+ }
+ if (!(obj instanceof TCP)) {
return false;
+ }
TCP other = (TCP) obj;
// May want to compare fields based on the flags set
return (checksum == other.checksum) &&
diff --git a/src/main/java/net/onrc/onos/core/packet/UDP.java b/src/main/java/net/onrc/onos/core/packet/UDP.java
index f12f34f..8411d8f 100644
--- a/src/main/java/net/onrc/onos/core/packet/UDP.java
+++ b/src/main/java/net/onrc/onos/core/packet/UDP.java
@@ -125,11 +125,13 @@
bb.putShort(this.destinationPort);
bb.putShort(this.length);
bb.putShort(this.checksum);
- if (payloadData != null)
+ if (payloadData != null) {
bb.put(payloadData);
+ }
- if (this.parent != null && this.parent instanceof IPv4)
+ if (this.parent != null && this.parent instanceof IPv4) {
((IPv4) this.parent).setProtocol(IPv4.PROTOCOL_UDP);
+ }
// compute checksum if needed
if (this.checksum == 0) {
@@ -182,21 +184,28 @@
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (!(obj instanceof UDP))
+ }
+ if (!(obj instanceof UDP)) {
return false;
+ }
UDP other = (UDP) obj;
- if (checksum != other.checksum)
+ if (checksum != other.checksum) {
return false;
- if (destinationPort != other.destinationPort)
+ }
+ if (destinationPort != other.destinationPort) {
return false;
- if (length != other.length)
+ }
+ if (length != other.length) {
return false;
- if (sourcePort != other.sourcePort)
+ }
+ if (sourcePort != other.sourcePort) {
return false;
+ }
return true;
}
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 4a0917e..496ae45 100755
--- a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
@@ -638,8 +638,9 @@
do {
try {
Participant leader = clusterLeaderLatch.getLeader();
- if (!leader.getId().isEmpty())
+ if (!leader.getId().isEmpty()) {
break;
+ }
Thread.sleep(CLUSTER_LEADER_ELECTION_RETRY_MS);
} catch (Exception e) {
log.error("Error on startup waiting for cluster leader election: {}", e.getMessage());
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);
diff --git a/src/main/java/net/onrc/onos/core/util/DataPath.java b/src/main/java/net/onrc/onos/core/util/DataPath.java
index 0c8b7c7..0a124e5 100644
--- a/src/main/java/net/onrc/onos/core/util/DataPath.java
+++ b/src/main/java/net/onrc/onos/core/util/DataPath.java
@@ -87,13 +87,15 @@
* @param flowPathFlags the Flow Path Flags to apply.
*/
public void applyFlowPathFlags(FlowPathFlags flowPathFlags) {
- if (flowPathFlags == null)
+ if (flowPathFlags == null) {
return; // Nothing to do
+ }
// Discard the first Flow Entry
if (flowPathFlags.isDiscardFirstHopEntry()) {
- if (flowEntries.size() > 0)
+ if (flowEntries.size() > 0) {
flowEntries.remove(0);
+ }
}
// Keep only the first Flow Entry
@@ -127,8 +129,9 @@
break;
}
}
- if (!foundDeletedFlowEntry)
+ if (!foundDeletedFlowEntry) {
return; // Nothing to do
+ }
// Create a new collection and exclude the deleted flow entries
ArrayList<FlowEntry> newFlowEntries = new ArrayList<FlowEntry>();
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntry.java b/src/main/java/net/onrc/onos/core/util/FlowEntry.java
index 0204590..768f942 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntry.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntry.java
@@ -144,8 +144,9 @@
*/
@JsonIgnore
public boolean isValidFlowId() {
- if (this.flowId == null)
+ if (this.flowId == null) {
return false;
+ }
return (this.flowId.isValid());
}
@@ -176,8 +177,9 @@
*/
@JsonIgnore
public boolean isValidFlowEntryId() {
- if (this.flowEntryId == null)
+ if (this.flowEntryId == null) {
return false;
+ }
return (this.flowEntryId.isValid());
}
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java b/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
index f619fea..cefc316 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
@@ -76,8 +76,9 @@
* @param other the object to copy from.
*/
public ActionOutput(ActionOutput other) {
- if (other.port != null)
+ if (other.port != null) {
this.port = new Port(other.port);
+ }
this.maxLen = other.maxLen;
}
@@ -168,8 +169,9 @@
String decode = null;
// Decode the "port=XXX" part
- if (parts.length > 0)
+ if (parts.length > 0) {
decode = parts[0];
+ }
if (decode != null) {
String[] tokens = decode.split("port=");
if (tokens.length > 1 && tokens[1] != null) {
@@ -186,8 +188,9 @@
// Decode the "maxLen=XXX" part
decode = null;
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
String[] tokens = decode.split("maxLen=");
@@ -287,8 +290,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -385,8 +389,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -483,8 +488,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
stripVlan = Boolean.valueOf(decode);
@@ -514,8 +520,9 @@
* @param other the object to copy from.
*/
public ActionSetEthernetAddr(ActionSetEthernetAddr other) {
- if (other.addr != null)
+ if (other.addr != null) {
this.addr = MACAddress.valueOf(other.addr.toLong());
+ }
}
/**
@@ -579,8 +586,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -614,8 +622,9 @@
* @param other the object to copy from.
*/
public ActionSetIPv4Addr(ActionSetIPv4Addr other) {
- if (other.addr != null)
+ if (other.addr != null) {
this.addr = new IPv4(other.addr);
+ }
}
/**
@@ -679,8 +688,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -778,8 +788,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -877,8 +888,9 @@
String decode = null;
// Decode the value
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
try {
@@ -915,8 +927,9 @@
* @param other the object to copy from.
*/
public ActionEnqueue(ActionEnqueue other) {
- if (other.port != null)
+ if (other.port != null) {
this.port = new Port(other.port);
+ }
this.queueId = other.queueId;
}
@@ -994,8 +1007,9 @@
String decode = null;
// Decode the "port=XXX" part
- if (parts.length > 0)
+ if (parts.length > 0) {
decode = parts[0];
+ }
if (decode != null) {
String[] tokens = decode.split("port=");
if (tokens.length > 1 && tokens[1] != null) {
@@ -1012,8 +1026,9 @@
// Decode the "queueId=XXX" part
decode = null;
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
+ }
if (decode != null) {
decode = decode.replace("]", "");
String[] tokens = decode.split("queueId=");
@@ -1065,65 +1080,77 @@
this.actionType = other.actionType;
//
- if (other.actionOutput != null)
+ if (other.actionOutput != null) {
this.actionOutput = new ActionOutput(other.actionOutput);
- else
+ } else {
this.actionOutput = null;
+ }
//
- if (other.actionSetVlanId != null)
+ if (other.actionSetVlanId != null) {
this.actionSetVlanId = new ActionSetVlanId(other.actionSetVlanId);
- else
+ } else {
this.actionSetVlanId = null;
+ }
//
- if (other.actionSetVlanPriority != null)
+ if (other.actionSetVlanPriority != null) {
this.actionSetVlanPriority = new ActionSetVlanPriority(other.actionSetVlanPriority);
- else
+ } else {
this.actionSetVlanPriority = null;
+ }
//
- if (other.actionStripVlan != null)
+ if (other.actionStripVlan != null) {
this.actionStripVlan = new ActionStripVlan(other.actionStripVlan);
- else
+ } else {
this.actionStripVlan = null;
+ }
//
- if (other.actionSetEthernetSrcAddr != null)
+ if (other.actionSetEthernetSrcAddr != null) {
this.actionSetEthernetSrcAddr = new ActionSetEthernetAddr(other.actionSetEthernetSrcAddr);
- else
+ } else {
this.actionSetEthernetSrcAddr = null;
+ }
//
- if (other.actionSetEthernetDstAddr != null)
+ if (other.actionSetEthernetDstAddr != null) {
this.actionSetEthernetDstAddr = new ActionSetEthernetAddr(other.actionSetEthernetDstAddr);
- else
+ } else {
this.actionSetEthernetDstAddr = null;
+ }
//
- if (other.actionSetIPv4SrcAddr != null)
+ if (other.actionSetIPv4SrcAddr != null) {
this.actionSetIPv4SrcAddr = new ActionSetIPv4Addr(other.actionSetIPv4SrcAddr);
- else
+ } else {
this.actionSetIPv4SrcAddr = null;
+ }
//
- if (other.actionSetIPv4DstAddr != null)
+ if (other.actionSetIPv4DstAddr != null) {
this.actionSetIPv4DstAddr = new ActionSetIPv4Addr(other.actionSetIPv4DstAddr);
- else
+ } else {
this.actionSetIPv4DstAddr = null;
+ }
//
- if (other.actionSetIpToS != null)
+ if (other.actionSetIpToS != null) {
this.actionSetIpToS = new ActionSetIpToS(other.actionSetIpToS);
- else
+ } else {
this.actionSetIpToS = null;
+ }
//
- if (other.actionSetTcpUdpSrcPort != null)
+ if (other.actionSetTcpUdpSrcPort != null) {
this.actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpSrcPort);
- else
+ } else {
this.actionSetTcpUdpSrcPort = null;
+ }
//
- if (other.actionSetTcpUdpDstPort != null)
+ if (other.actionSetTcpUdpDstPort != null) {
this.actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpDstPort);
- else
+ } else {
this.actionSetTcpUdpDstPort = null;
+ }
//
- if (other.actionEnqueue != null)
+ if (other.actionEnqueue != null) {
this.actionEnqueue = new ActionEnqueue(other.actionEnqueue);
- else
+ } else {
this.actionEnqueue = null;
+ }
}
/**
@@ -1603,10 +1630,12 @@
String decode = null;
// Extract the string after the "type="
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
- if (decode == null)
+ }
+ if (decode == null) {
throw new IllegalArgumentException("Invalid action string");
+ }
// Remove the trailing ']'
if ((decode.length() > 0) && (decode.charAt(decode.length() - 1) == ']')) {
@@ -1619,8 +1648,9 @@
parts = decode.split(" action=");
// Decode the "type=XXX" payload
- if (parts.length > 0)
+ if (parts.length > 0) {
decode = parts[0];
+ }
if (decode != null) {
try {
actionType = Enum.valueOf(ActionValues.class, decode);
@@ -1633,10 +1663,12 @@
// Decode the "action=XXX" payload
decode = null;
- if (parts.length > 1)
+ if (parts.length > 1) {
decode = parts[1];
- if (decode == null)
+ }
+ if (decode == null) {
throw new IllegalArgumentException("Invalid action string");
+ }
//
try {
switch (actionType) {
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryActions.java b/src/main/java/net/onrc/onos/core/util/FlowEntryActions.java
index 421312e..62d9a65 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryActions.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryActions.java
@@ -119,8 +119,9 @@
actions = new ArrayList<FlowEntryAction>();
- if (decode.isEmpty())
+ if (decode.isEmpty()) {
return; // Nothing to do
+ }
// Remove the '[' and ']' in the beginning and the end of the string
if ((decode.length() > 1) && (decode.charAt(0) == '[') &&
@@ -134,8 +135,9 @@
String[] parts = decode.split(";");
for (int i = 0; i < parts.length; i++) {
decode = parts[i];
- if ((decode == null) || decode.isEmpty())
+ if ((decode == null) || decode.isEmpty()) {
continue;
+ }
FlowEntryAction flowEntryAction = null;
try {
flowEntryAction = new FlowEntryAction(decode);
@@ -143,8 +145,9 @@
// TODO: Ignore invalid actions for now
continue;
}
- if (flowEntryAction != null)
+ if (flowEntryAction != null) {
actions.add(flowEntryAction);
+ }
}
}
}
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryId.java b/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
index 5b19e91..a46549f 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
@@ -46,12 +46,14 @@
// large unsigned hex long values.
//
char c = 0;
- if (value.length() > 2)
+ if (value.length() > 2) {
c = value.charAt(1);
- if ((c == 'x') || (c == 'X'))
+ }
+ if ((c == 'x') || (c == 'X')) {
this.value = new BigInteger(value.substring(2), 16).longValue();
- else
+ } else {
this.value = Long.decode(value);
+ }
}
/**
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 ce6a202..f0b1152 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryMatch.java
@@ -98,30 +98,42 @@
* @param other the object to copy from.
*/
public FlowEntryMatch(FlowEntryMatch other) {
- if ((other.inPort != null) && other.inPort.enabled())
+ if ((other.inPort != null) && other.inPort.enabled()) {
this.enableInPort(other.inPort.value());
- if ((other.srcMac != null) && other.srcMac.enabled())
+ }
+ if ((other.srcMac != null) && other.srcMac.enabled()) {
this.enableSrcMac(other.srcMac.value());
- if ((other.dstMac != null) && other.dstMac.enabled())
+ }
+ if ((other.dstMac != null) && other.dstMac.enabled()) {
this.enableDstMac(other.dstMac.value());
- if ((other.ethernetFrameType != null) && other.ethernetFrameType.enabled())
+ }
+ if ((other.ethernetFrameType != null) && other.ethernetFrameType.enabled()) {
this.enableEthernetFrameType(other.ethernetFrameType.value());
- if ((other.vlanId != null) && other.vlanId.enabled())
+ }
+ if ((other.vlanId != null) && other.vlanId.enabled()) {
this.enableVlanId(other.vlanId.value());
- if ((other.vlanPriority != null) && other.vlanPriority.enabled())
+ }
+ if ((other.vlanPriority != null) && other.vlanPriority.enabled()) {
this.enableVlanPriority(other.vlanPriority.value());
- if ((other.srcIPv4Net != null) && other.srcIPv4Net.enabled())
+ }
+ if ((other.srcIPv4Net != null) && other.srcIPv4Net.enabled()) {
this.enableSrcIPv4Net(other.srcIPv4Net.value());
- if ((other.dstIPv4Net != null) && other.dstIPv4Net.enabled())
+ }
+ if ((other.dstIPv4Net != null) && other.dstIPv4Net.enabled()) {
this.enableDstIPv4Net(other.dstIPv4Net.value());
- if ((other.ipProto != null) && other.ipProto.enabled())
+ }
+ if ((other.ipProto != null) && other.ipProto.enabled()) {
this.enableIpProto(other.ipProto.value());
- if ((other.ipToS != null) && other.ipToS.enabled())
+ }
+ if ((other.ipToS != null) && other.ipToS.enabled()) {
this.enableIpToS(other.ipToS.value());
- if ((other.srcTcpUdpPort != null) && other.srcTcpUdpPort.enabled())
+ }
+ if ((other.srcTcpUdpPort != null) && other.srcTcpUdpPort.enabled()) {
this.enableSrcTcpUdpPort(other.srcTcpUdpPort.value());
- if ((other.dstTcpUdpPort != null) && other.dstTcpUdpPort.enabled())
+ }
+ if ((other.dstTcpUdpPort != null) && other.dstTcpUdpPort.enabled()) {
this.enableDstTcpUdpPort(other.dstTcpUdpPort.value());
+ }
}
/**
@@ -131,8 +143,9 @@
*/
@JsonProperty("inPort")
public Port inPort() {
- if (inPort != null)
+ if (inPort != null) {
return inPort.value();
+ }
return null;
}
@@ -160,8 +173,9 @@
*/
@JsonProperty("matchInPort")
public boolean matchInPort() {
- if (inPort != null)
+ if (inPort != null) {
return inPort.enabled();
+ }
return false;
}
@@ -172,8 +186,9 @@
*/
@JsonProperty("srcMac")
public MACAddress srcMac() {
- if (srcMac != null)
+ if (srcMac != null) {
return srcMac.value();
+ }
return null;
}
@@ -201,8 +216,9 @@
*/
@JsonProperty("matchSrcMac")
public boolean matchSrcMac() {
- if (srcMac != null)
+ if (srcMac != null) {
return srcMac.enabled();
+ }
return false;
}
@@ -213,8 +229,9 @@
*/
@JsonProperty("dstMac")
public MACAddress dstMac() {
- if (dstMac != null)
+ if (dstMac != null) {
return dstMac.value();
+ }
return null;
}
@@ -242,8 +259,9 @@
*/
@JsonProperty("matchDstMac")
public boolean matchDstMac() {
- if (dstMac != null)
+ if (dstMac != null) {
return dstMac.enabled();
+ }
return false;
}
@@ -254,8 +272,9 @@
*/
@JsonProperty("ethernetFrameType")
public Short ethernetFrameType() {
- if (ethernetFrameType != null)
+ if (ethernetFrameType != null) {
return ethernetFrameType.value();
+ }
return null;
}
@@ -284,8 +303,9 @@
*/
@JsonProperty("matchEthernetFrameType")
public boolean matchEthernetFrameType() {
- if (ethernetFrameType != null)
+ if (ethernetFrameType != null) {
return ethernetFrameType.enabled();
+ }
return false;
}
@@ -296,8 +316,9 @@
*/
@JsonProperty("vlanId")
public Short vlanId() {
- if (vlanId != null)
+ if (vlanId != null) {
return vlanId.value();
+ }
return null;
}
@@ -325,8 +346,9 @@
*/
@JsonProperty("matchVlanId")
public boolean matchVlanId() {
- if (vlanId != null)
+ if (vlanId != null) {
return vlanId.enabled();
+ }
return false;
}
@@ -337,8 +359,9 @@
*/
@JsonProperty("vlanPriority")
public Byte vlanPriority() {
- if (vlanPriority != null)
+ if (vlanPriority != null) {
return vlanPriority.value();
+ }
return null;
}
@@ -366,8 +389,9 @@
*/
@JsonProperty("matchVlanPriority")
public boolean matchVlanPriority() {
- if (vlanPriority != null)
+ if (vlanPriority != null) {
return vlanPriority.enabled();
+ }
return false;
}
@@ -378,8 +402,9 @@
*/
@JsonProperty("srcIPv4Net")
public IPv4Net srcIPv4Net() {
- if (srcIPv4Net != null)
+ if (srcIPv4Net != null) {
return srcIPv4Net.value();
+ }
return null;
}
@@ -407,8 +432,9 @@
*/
@JsonProperty("matchSrcIPv4Net")
public boolean matchSrcIPv4Net() {
- if (srcIPv4Net != null)
+ if (srcIPv4Net != null) {
return srcIPv4Net.enabled();
+ }
return false;
}
@@ -419,8 +445,9 @@
*/
@JsonProperty("dstIPv4Net")
public IPv4Net dstIPv4Net() {
- if (dstIPv4Net != null)
+ if (dstIPv4Net != null) {
return dstIPv4Net.value();
+ }
return null;
}
@@ -449,8 +476,9 @@
*/
@JsonProperty("matchDstIPv4Net")
public boolean matchDstIPv4Net() {
- if (dstIPv4Net != null)
+ if (dstIPv4Net != null) {
return dstIPv4Net.enabled();
+ }
return false;
}
@@ -461,8 +489,9 @@
*/
@JsonProperty("ipProto")
public Byte ipProto() {
- if (ipProto != null)
+ if (ipProto != null) {
return ipProto.value();
+ }
return null;
}
@@ -490,8 +519,9 @@
*/
@JsonProperty("matchIpProto")
public boolean matchIpProto() {
- if (ipProto != null)
+ if (ipProto != null) {
return ipProto.enabled();
+ }
return false;
}
@@ -502,8 +532,9 @@
*/
@JsonProperty("ipToS")
public Byte ipToS() {
- if (ipToS != null)
+ if (ipToS != null) {
return ipToS.value();
+ }
return null;
}
@@ -531,8 +562,9 @@
*/
@JsonProperty("matchIpToS")
public boolean matchIpToS() {
- if (ipToS != null)
+ if (ipToS != null) {
return ipToS.enabled();
+ }
return false;
}
@@ -543,8 +575,9 @@
*/
@JsonProperty("srcTcpUdpPort")
public Short srcTcpUdpPort() {
- if (srcTcpUdpPort != null)
+ if (srcTcpUdpPort != null) {
return srcTcpUdpPort.value();
+ }
return null;
}
@@ -572,8 +605,9 @@
*/
@JsonProperty("matchSrcTcpUdpPort")
public boolean matchSrcTcpUdpPort() {
- if (srcTcpUdpPort != null)
+ if (srcTcpUdpPort != null) {
return srcTcpUdpPort.enabled();
+ }
return false;
}
@@ -584,8 +618,9 @@
*/
@JsonProperty("dstTcpUdpPort")
public Short dstTcpUdpPort() {
- if (dstTcpUdpPort != null)
+ if (dstTcpUdpPort != null) {
return dstTcpUdpPort.value();
+ }
return null;
}
@@ -614,8 +649,9 @@
*/
@JsonProperty("matchDstTcpUdpPort")
public boolean matchDstTcpUdpPort() {
- if (dstTcpUdpPort != null)
+ if (dstTcpUdpPort != null) {
return dstTcpUdpPort.enabled();
+ }
return false;
}
@@ -636,74 +672,86 @@
// Conditionally add only those matching fields that are enabled
//
if (matchInPort()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "inPort=" + this.inPort().toString();
}
if (matchSrcMac()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "srcMac=" + this.srcMac().toString();
}
if (matchDstMac()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "dstMac=" + this.dstMac().toString();
}
if (matchEthernetFrameType()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "ethernetFrameType=" + this.ethernetFrameType().toString();
}
if (matchVlanId()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "vlanId=" + this.vlanId().toString();
}
if (matchVlanPriority()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "vlanPriority=" + this.vlanPriority().toString();
}
if (matchSrcIPv4Net()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "srcIPv4Net=" + this.srcIPv4Net().toString();
}
if (matchDstIPv4Net()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "dstIPv4Net=" + this.dstIPv4Net().toString();
}
if (matchIpProto()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "ipProto=" + this.ipProto().toString();
}
if (matchIpToS()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "ipToS=" + this.ipToS().toString();
}
if (matchSrcTcpUdpPort()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "srcTcpUdpPort=" + this.srcTcpUdpPort().toString();
}
if (matchDstTcpUdpPort()) {
- if (addSpace)
+ if (addSpace) {
ret += " ";
+ }
addSpace = true;
ret += "dstTcpUdpPort=" + this.dstTcpUdpPort().toString();
}
diff --git a/src/main/java/net/onrc/onos/core/util/FlowId.java b/src/main/java/net/onrc/onos/core/util/FlowId.java
index d397918..a889fb3 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowId.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowId.java
@@ -46,12 +46,14 @@
// large unsigned hex long values.
//
char c = 0;
- if (value.length() > 2)
+ if (value.length() > 2) {
c = value.charAt(1);
- if ((c == 'x') || (c == 'X'))
+ }
+ if ((c == 'x') || (c == 'X')) {
this.value = new BigInteger(value.substring(2), 16).longValue();
- else
+ } else {
this.value = Long.decode(value);
+ }
}
/**
diff --git a/src/main/java/net/onrc/onos/core/util/FlowPath.java b/src/main/java/net/onrc/onos/core/util/FlowPath.java
index 0286bd2..2314dfc 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowPath.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowPath.java
@@ -64,8 +64,9 @@
*/
@JsonIgnore
public boolean isValidFlowId() {
- if (this.flowId == null)
+ if (this.flowId == null) {
return false;
+ }
return (this.flowId.isValid());
}
@@ -316,12 +317,15 @@
ret += " idleTimeout=" + this.idleTimeout;
ret += " hardTimeout=" + this.hardTimeout;
ret += " priority=" + this.priority;
- if (dataPath != null)
+ if (dataPath != null) {
ret += " dataPath=" + this.dataPath.toString();
- if (flowEntryMatch != null)
+ }
+ if (flowEntryMatch != null) {
ret += " flowEntryMatch=" + this.flowEntryMatch.toString();
- if (flowEntryActions != null)
+ }
+ if (flowEntryActions != null) {
ret += " flowEntryActions=" + this.flowEntryActions.toString();
+ }
ret += "]";
return ret;
}
diff --git a/src/main/java/net/onrc/onos/core/util/FlowPathFlags.java b/src/main/java/net/onrc/onos/core/util/FlowPathFlags.java
index e1e67c5..138f961 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowPathFlags.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowPathFlags.java
@@ -75,10 +75,12 @@
this.flags = 0L;
// Test all flags
- if (flagsStr.contains("DISCARD_FIRST_HOP_ENTRY"))
+ if (flagsStr.contains("DISCARD_FIRST_HOP_ENTRY")) {
this.flags |= DISCARD_FIRST_HOP_ENTRY;
- if (flagsStr.contains("KEEP_ONLY_FIRST_HOP_ENTRY"))
+ }
+ if (flagsStr.contains("KEEP_ONLY_FIRST_HOP_ENTRY")) {
this.flags |= KEEP_ONLY_FIRST_HOP_ENTRY;
+ }
}
/**
@@ -119,12 +121,14 @@
flagsStr += "DISCARD_FIRST_HOP_ENTRY";
}
if ((this.flags & KEEP_ONLY_FIRST_HOP_ENTRY) != 0) {
- if (flagsStr != null)
+ if (flagsStr != null) {
flagsStr += ",";
+ }
flagsStr += "KEEP_ONLY_FIRST_HOP_ENTRY";
}
- if (flagsStr != null)
+ if (flagsStr != null) {
ret += flagsStr;
+ }
ret += "]";
return ret;
diff --git a/src/main/java/net/onrc/onos/core/util/IPv4.java b/src/main/java/net/onrc/onos/core/util/IPv4.java
index b25099a..0b5c081 100644
--- a/src/main/java/net/onrc/onos/core/util/IPv4.java
+++ b/src/main/java/net/onrc/onos/core/util/IPv4.java
@@ -47,9 +47,10 @@
*/
public IPv4(String value) {
String[] splits = value.split("\\.");
- if (splits.length != 4)
+ if (splits.length != 4) {
throw new IllegalArgumentException("Specified IPv4 address must contain four " +
"numerical digits separated by '.'");
+ }
int result = 0;
for (int i = 0; i < 4; ++i) {
diff --git a/src/main/java/net/onrc/onos/core/util/IPv4Net.java b/src/main/java/net/onrc/onos/core/util/IPv4Net.java
index 6a04635..3b8fad6 100644
--- a/src/main/java/net/onrc/onos/core/util/IPv4Net.java
+++ b/src/main/java/net/onrc/onos/core/util/IPv4Net.java
@@ -30,10 +30,11 @@
* @param other the object to copy from.
*/
public IPv4Net(IPv4Net other) {
- if (other.address != null)
+ if (other.address != null) {
this.address = new IPv4(other.address);
- else
+ } else {
this.address = null;
+ }
this.prefixLen = other.prefixLen;
}
diff --git a/src/main/java/net/onrc/onos/core/util/IPv6Net.java b/src/main/java/net/onrc/onos/core/util/IPv6Net.java
index 72ec5e9..064e22e 100644
--- a/src/main/java/net/onrc/onos/core/util/IPv6Net.java
+++ b/src/main/java/net/onrc/onos/core/util/IPv6Net.java
@@ -30,10 +30,11 @@
* @param other the object to copy from.
*/
public IPv6Net(IPv6Net other) {
- if (other.address != null)
+ if (other.address != null) {
this.address = new IPv6(other.address);
- else
+ } else {
this.address = null;
+ }
this.prefixLen = other.prefixLen;
}