Skip to content
Permalink
Browse files

fix: squid:S1206 -equals(Object obj) and hashCode() should be overrid…

…den in pairs

closes #515
  • Loading branch information
George Kankava authored and vlsi committed Feb 19, 2016
1 parent 9109451 commit a07d6d395e6c7b8f3c55b2c535e5719ec431af02
@@ -113,6 +113,7 @@
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="EqualsHashCode"/>
<!--<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
@@ -67,6 +67,16 @@ public void setValue(String s) throws SQLException {
}
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
long temp;
temp = Double.doubleToLongBits(val);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}

public boolean equals(Object obj) {
if (obj instanceof PGmoney) {
PGmoney p = (PGmoney) obj;
@@ -30,6 +30,16 @@ public int getFormatId() {
return branchQualifier;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(branchQualifier);
result = prime * result + formatId;
result = prime * result + Arrays.hashCode(globalTransactionId);
return result;
}

public boolean equals(Object o) {
if (o == this) {
// optimization for the common case.
@@ -126,6 +126,10 @@ public int getFormatId() {
}

public boolean equals(Object o) {
if (!(o instanceof Xid)) {
return false;
}

Xid other = (Xid) o;
if (other.getFormatId() != this.getFormatId()) {
return false;
@@ -139,6 +143,16 @@ public boolean equals(Object o) {

return true;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(getBranchQualifier());
result = prime * result + getFormatId();
result = prime * result + Arrays.hashCode(getGlobalTransactionId());
return result;
}
}

/*

0 comments on commit a07d6d3

Please sign in to comment.
You can’t perform that action at this time.