Enable checkstyle check for blocks without braces.
Enable the checkstyle rule to check for block statements
without curly braces and fix any violations it finds.
Change-Id: Id4c58cea26f0d9ce7ed78643a4943c042886a12d
diff --git a/src/main/java/net/onrc/onos/core/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;
}