Removed Equals/HashCodeBuilder for ARP/LLDPTLV 23/423/3
authorEd Warnicke <eaw@cisco.com>
Mon, 3 Jun 2013 22:41:14 +0000 (17:41 -0500)
committerGiovanni Meo <gmeo@cisco.com>
Wed, 5 Jun 2013 13:45:33 +0000 (15:45 +0200)
This also entailed fixing equals and HashCodeBuilder for Packet.

Change-Id: I5497a719d51becfd0019fada2c7f171fadfbdb13
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java

index f3aa35f637bdc2e0346beffe8899d0b56b6bb24c..dd51e85f20ee4bd9b6ba2d9e64ac0965a1fc33b2 100644 (file)
@@ -13,8 +13,6 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 
@@ -249,11 +247,27 @@ public class ARP extends Packet {
 
     @Override
     public int hashCode() {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ARP other = (ARP) obj;
+        if (fieldValues == null) {
+            if (other.fieldValues != null)
+                return false;
+        } else if (!fieldValues.equals(other.fieldValues))
+            return false;
+        return true;
     }
 }
     }
 }
index 9254e824c57494a528a8e40bcf2052e0e7ab5fdd..bf674022596d8eb09df2b99bdb72314bdbdaf2cc 100644 (file)
@@ -10,13 +10,11 @@ package org.opendaylight.controller.sal.packet;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
-import java.util.HashMap;
-
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.sal.utils.HexEncode;
@@ -144,12 +142,28 @@ public class LLDPTLV extends Packet {
 
     @Override
     public int hashCode() {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        LLDPTLV other = (LLDPTLV) obj;
+        if (fieldValues == null) {
+            if (other.fieldValues != null)
+                return false;
+        } else if (!fieldValues.equals(other.fieldValues))
+            return false;
+        return true;
     }
 
     @Override
     }
 
     @Override
@@ -164,7 +178,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Returns the size in bits of the whole TLV
 
     /**
      * Returns the size in bits of the whole TLV
-     * 
+     *
      * @return int - size in bits of full TLV
      */
     public int getTLVSize() {
      * @return int - size in bits of full TLV
      */
     public int getTLVSize() {
@@ -176,7 +190,7 @@ public class LLDPTLV extends Packet {
     /**
      * Creates the ChassisID TLV value including the subtype and ChassisID
      * string
     /**
      * Creates the ChassisID TLV value including the subtype and ChassisID
      * string
-     * 
+     *
      * @param nodeId
      *            node identifier string
      * @return the ChassisID TLV value in byte array
      * @param nodeId
      *            node identifier string
      * @return the ChassisID TLV value in byte array
@@ -204,7 +218,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Creates the PortID TLV value including the subtype and PortID string
 
     /**
      * Creates the PortID TLV value including the subtype and PortID string
-     * 
+     *
      * @param portId
      *            port identifier string
      * @return the PortID TLV value in byte array
      * @param portId
      *            port identifier string
      * @return the PortID TLV value in byte array
@@ -221,7 +235,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Creates the custom TLV value including OUI, subtype and custom string
 
     /**
      * Creates the custom TLV value including OUI, subtype and custom string
-     * 
+     *
      * @param portId
      *            port identifier string
      * @return the custom TLV value in byte array
      * @param portId
      *            port identifier string
      * @return the custom TLV value in byte array
@@ -241,7 +255,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Retrieves the string from TLV value and returns it in HexString format
 
     /**
      * Retrieves the string from TLV value and returns it in HexString format
-     * 
+     *
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
@@ -257,7 +271,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Retrieves the string from TLV value
 
     /**
      * Retrieves the string from TLV value
-     * 
+     *
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
@@ -274,7 +288,7 @@ public class LLDPTLV extends Packet {
     /**
      * Retrieves the custom string from the Custom TLV value which includes OUI,
      * subtype and custom string
     /**
      * Retrieves the custom string from the Custom TLV value which includes OUI,
      * subtype and custom string
-     * 
+     *
      * @param customTlvValue
      *            the custom TLV value
      * @param customTlvLen
      * @param customTlvValue
      *            the custom TLV value
      * @param customTlvLen
index b19c0f862b9e559219d5a00e8a3d289122a6c1a8..58b5d3914aa2dc199111dd2f2dc1ff8d5289dcc0 100644 (file)
@@ -77,7 +77,7 @@ public abstract class Packet {
     /**
      * This method deserializes the data bits obtained from the wire into the
      * respective header and payload which are of type Packet
     /**
      * This method deserializes the data bits obtained from the wire into the
      * respective header and payload which are of type Packet
-     * 
+     *
      * @param byte[] data - data from wire to deserialize
      * @param int bitOffset bit position where packet header starts in data
      *        array
      * @param byte[] data - data from wire to deserialize
      * @param int bitOffset bit position where packet header starts in data
      *        array
@@ -151,7 +151,7 @@ public abstract class Packet {
     /**
      * This method serializes the header and payload from the respective
      * packet class, into a single stream of bytes to be sent on the wire
     /**
      * This method serializes the header and payload from the respective
      * packet class, into a single stream of bytes to be sent on the wire
-     * 
+     *
      * @return The byte array representing the serialized Packet
      * @throws PacketException
      */
      * @return The byte array representing the serialized Packet
      * @throws PacketException
      */
@@ -206,7 +206,7 @@ public abstract class Packet {
      * byte stream which cannot be done or cannot be done efficiently during the
      * normal Packet.serialize() path. An example is the checksum computation
      * for IPv4
      * byte stream which cannot be done or cannot be done efficiently during the
      * normal Packet.serialize() path. An example is the checksum computation
      * for IPv4
-     * 
+     *
      * @param byte[] - serialized bytes
      * @throws PacketException
      */
      * @param byte[] - serialized bytes
      * @throws PacketException
      */
@@ -221,7 +221,7 @@ public abstract class Packet {
      * of checksum varies based on the protocol, this method is overridden.
      * Currently only IPv4 and ICMP do checksum computation and validation. TCP
      * and UDP need to implement these if required.
      * of checksum varies based on the protocol, this method is overridden.
      * Currently only IPv4 and ICMP do checksum computation and validation. TCP
      * and UDP need to implement these if required.
-     * 
+     *
      * @param byte[] data The byte stream representing the Ethernet frame
      * @param int startBitOffset The bit offset from where the byte array corresponding to this Packet starts in the frame
      * @throws PacketException
      * @param byte[] data The byte stream representing the Ethernet frame
      * @param int startBitOffset The bit offset from where the byte array corresponding to this Packet starts in the frame
      * @throws PacketException
@@ -233,7 +233,7 @@ public abstract class Packet {
 
     /**
      * Gets the header length in bits
 
     /**
      * Gets the header length in bits
-     * 
+     *
      * @return int the header length in bits
      */
     public int getHeaderSize() {
      * @return int the header length in bits
      */
     public int getHeaderSize() {
@@ -256,7 +256,7 @@ public abstract class Packet {
      * This method fetches the start bit offset for header field specified by
      * 'fieldname'. The offset is present in the hdrFieldCoordMap of the
      * respective packet class
      * This method fetches the start bit offset for header field specified by
      * 'fieldname'. The offset is present in the hdrFieldCoordMap of the
      * respective packet class
-     * 
+     *
      * @param String
      *            fieldName
      * @return Integer - startOffset of the requested field
      * @param String
      *            fieldName
      * @return Integer - startOffset of the requested field
@@ -269,7 +269,7 @@ public abstract class Packet {
      * This method fetches the number of bits for header field specified by
      * 'fieldname'. The numBits are present in the hdrFieldCoordMap of the
      * respective packet class
      * This method fetches the number of bits for header field specified by
      * 'fieldname'. The numBits are present in the hdrFieldCoordMap of the
      * respective packet class
-     * 
+     *
      * @param String
      *            fieldName
      * @return Integer - number of bits of the requested field
      * @param String
      *            fieldName
      * @return Integer - number of bits of the requested field
@@ -297,7 +297,7 @@ public abstract class Packet {
     /**
      * Returns the raw payload carried by this packet in case payload was not
      * parsed. Caller can call this function in case the getPaylod() returns null.
     /**
      * Returns the raw payload carried by this packet in case payload was not
      * parsed. Caller can call this function in case the getPaylod() returns null.
-     * 
+     *
      * @return The raw payload if not parsable as an array of bytes, null otherwise
      */
     public byte[] getRawPayload() {
      * @return The raw payload if not parsable as an array of bytes, null otherwise
      */
     public byte[] getRawPayload() {
@@ -306,7 +306,7 @@ public abstract class Packet {
 
     /**
      * Set a raw payload in the packet class
 
     /**
      * Set a raw payload in the packet class
-     * 
+     *
      * @param payload The raw payload as byte array
      */
     public void setRawPayload(byte[] payload) {
      * @param payload The raw payload as byte array
      */
     public void setRawPayload(byte[] payload) {
@@ -319,8 +319,8 @@ public abstract class Packet {
      * packet received from wire is not equal to the checksum read from the
      * stream. For the Packet class which do not have a checksum field, this
      * function will always return false.
      * packet received from wire is not equal to the checksum read from the
      * stream. For the Packet class which do not have a checksum field, this
      * function will always return false.
-     * 
-     * 
+     *
+     *
      * @return true if the deserialized packet's recomputed checksum is not
      *         equal to the packet carried checksum
      */
      * @return true if the deserialized packet's recomputed checksum is not
      *         equal to the packet carried checksum
      */