From: Ed Warnicke Date: Wed, 15 May 2013 16:17:48 +0000 (-0500) Subject: Six more Equals/HashCode/StringBuilder replacements X-Git-Tag: releasepom-0.1.0~448^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=fcab1998a98eef2d040118b71562a9e155977ae0 Six more Equals/HashCode/StringBuilder replacements I'm intentionally breaking these up into small groups so they can be reasonably reviewed, rather than one giant group that can't. Contributes to fixing bug 20. Fourth in set. Change-Id: Ic24cd900b1b88a1496c5f0a14f8f24650c00b297 Signed-off-by: Ed Warnicke --- diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java index 33c96d3738..69fdd89ffb 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set network TOS action */ @@ -47,13 +44,25 @@ public class SetNwTos extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetNwTos other = (SetNwTos) obj; + if (tos != other.tos) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + tos; + return result; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java index fb7c824494..825092c54f 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set destination transport port action */ @@ -46,13 +43,25 @@ public class SetTpDst extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetTpDst other = (SetTpDst) obj; + if (port != other.port) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + port; + return result; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java index 20210ad5e8..cdae5aad2a 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set source transport port action * @@ -47,13 +44,25 @@ public class SetTpSrc extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetTpSrc other = (SetTpSrc) obj; + if (port != other.port) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + port; + return result; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java index c21430e9e9..fc3d0a60ef 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set vlan CFI action * @@ -47,13 +44,25 @@ public class SetVlanCfi extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetVlanCfi other = (SetVlanCfi) obj; + if (cfi != other.cfi) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + cfi; + return result; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java index 9c9b364b89..b1e4748bc3 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set vlan id action */ @@ -48,13 +45,25 @@ public class SetVlanId extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetVlanId other = (SetVlanId) obj; + if (vlanId != other.vlanId) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + vlanId; + return result; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java index 5c315debff..c47723ebdf 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java @@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Set vlan PCP action */ @@ -46,13 +43,25 @@ public class SetVlanPcp extends Action { } @Override - public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SetVlanPcp other = (SetVlanPcp) obj; + if (pcp != other.pcp) + return false; + return true; } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + pcp; + return result; } @Override