X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2FBandwidth.java;h=30f27793dea433b8c07defe6335c709024eb8184;hb=18fa9cb41678400d1decd007a66fc1f7be894f66;hp=32f661ca5ff29a7a14d284068692d45d83638e46;hpb=42210c03b0a4c54706320ba9f55794c0abd4d201;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java index 32f661ca5f..30f27793de 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java @@ -9,12 +9,11 @@ package org.opendaylight.controller.sal.core; +import javax.xml.bind.annotation.XmlAccessType; +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; - /** * @file BandWidth.java * @@ -25,10 +24,11 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; * seconds. */ @XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) public class Bandwidth extends Property { private static final long serialVersionUID = 1L; - @XmlElement + @XmlElement(name="value") protected long bandwidthValue; public static final long BWUNK = 0; @@ -52,7 +52,6 @@ public class Bandwidth extends Property { private Bandwidth() { super(BandwidthPropName); this.bandwidthValue = BWUNK; - ; } public Bandwidth(long bandwidth) { @@ -69,11 +68,12 @@ public class Bandwidth extends Property { super(BandwidthPropName); this.bandwidthValue = (long) bandwidth; } - + public Bandwidth(String name) { super(name); } + @Override public Bandwidth clone() { return new Bandwidth(this.bandwidthValue); } @@ -84,34 +84,48 @@ public class Bandwidth extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + (int) (bandwidthValue ^ (bandwidthValue >>> 32)); + return result; } @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; + Bandwidth other = (Bandwidth) obj; + if (bandwidthValue != other.bandwidthValue) + return false; + return true; } @Override public String toString() { - StringBuffer sb = new StringBuffer(); + return "BandWidth[" + getStringValue() + "]"; + } - sb.append("BandWidth["); + @Override + public String getStringValue() { if (this.bandwidthValue == 0) { - sb.append("UnKnown"); + return("UnKnown"); } else if (this.bandwidthValue < BW1Kbps) { - sb.append(this.bandwidthValue + "bps"); + return(this.bandwidthValue + "bps"); } else if (this.bandwidthValue < BW1Mbps) { - sb.append(Long.toString(this.bandwidthValue / BW1Kbps) + "Kbps"); + return(Long.toString(this.bandwidthValue / BW1Kbps) + "Kbps"); } else if (this.bandwidthValue < BW1Gbps) { - sb.append(Long.toString(this.bandwidthValue / BW1Mbps) + "Mbps"); + return(Long.toString(this.bandwidthValue / BW1Mbps) + "Mbps"); } else if (this.bandwidthValue < BW1Tbps) { - sb.append(Long.toString(this.bandwidthValue / BW1Gbps) + "Gbps"); + return(Long.toString(this.bandwidthValue / BW1Gbps) + "Gbps"); } else if (this.bandwidthValue < BW1Pbps) { - sb.append(Long.toString(this.bandwidthValue / BW1Tbps) + "Tbps"); + return(Long.toString(this.bandwidthValue / BW1Tbps) + "Tbps"); + } else { + return(this.bandwidthValue + "bps"); } - - sb.append("]"); - return sb.toString(); } }