HBASE-7601 Fix 8 remaining EQ findbug warnings from hbase-server.

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1435487 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-01-19 05:05:50 +00:00
parent da18540ea3
commit b96d60d659
8 changed files with 82 additions and 1 deletions

View File

@ -28,7 +28,7 @@ import org.apache.hadoop.classification.InterfaceStability;
*/ */
@InterfaceAudience.Public @InterfaceAudience.Public
@InterfaceStability.Stable @InterfaceStability.Stable
public class Action<R> implements Comparable { public class Action<R> implements Comparable<R> {
private Row action; private Row action;
private int originalIndex; private int originalIndex;
@ -77,4 +77,12 @@ public class Action<R> implements Comparable {
public int compareTo(Object o) { public int compareTo(Object o) {
return action.compareTo(((Action) o).getAction()); return action.compareTo(((Action) o).getAction());
} }
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Action<?> other = (Action<?>) obj;
return compareTo(other) == 0;
}
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.hadoop.hbase.client; package org.apache.hadoop.hbase.client;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
@ -418,8 +419,20 @@ public class Get extends OperationWithAttributes
} }
//Row //Row
@Override
public int compareTo(Row other) { public int compareTo(Row other) {
return Bytes.compareTo(this.getRow(), other.getRow()); return Bytes.compareTo(this.getRow(), other.getRow());
} }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Row other = (Row) obj;
return compareTo(other) == 0;
}
} }

View File

@ -274,4 +274,16 @@ public class Increment implements Row {
public int compareTo(Row i) { public int compareTo(Row i) {
return Bytes.compareTo(this.getRow(), i.getRow()); return Bytes.compareTo(this.getRow(), i.getRow());
} }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Row other = (Row) obj;
return compareTo(other) == 0;
}
} }

View File

@ -43,6 +43,11 @@ public class NullComparator extends ByteArrayComparable {
return value != null ? 1 : 0; return value != null ? 1 : 0;
} }
@Override
public boolean equals(Object obj) {
return obj == null;
}
@Override @Override
public int compareTo(byte[] value, int offset, int length) { public int compareTo(byte[] value, int offset, int length) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -96,11 +96,24 @@ public class CachedBlock implements HeapSize, Comparable<CachedBlock> {
return size; return size;
} }
@Override
public int compareTo(CachedBlock that) { public int compareTo(CachedBlock that) {
if(this.accessTime == that.accessTime) return 0; if(this.accessTime == that.accessTime) return 0;
return this.accessTime < that.accessTime ? 1 : -1; return this.accessTime < that.accessTime ? 1 : -1;
} }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
CachedBlock other = (CachedBlock) obj;
return compareTo(other) == 0;
}
public Cacheable getBuffer() { public Cacheable getBuffer() {
return this.buf; return this.buf;
} }

View File

@ -106,7 +106,20 @@ public class TableSplit implements InputSplit, Comparable<TableSplit> {
Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow); Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow);
} }
@Override
public int compareTo(TableSplit o) { public int compareTo(TableSplit o) {
return Bytes.compareTo(getStartRow(), o.getStartRow()); return Bytes.compareTo(getStartRow(), o.getStartRow());
} }
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof TableSplit)) {
return false;
}
TableSplit other = (TableSplit)o;
return Bytes.equals(m_tableName, other.m_tableName) &&
Bytes.equals(m_startRow, other.m_startRow) &&
Bytes.equals(m_endRow, other.m_endRow) &&
m_regionLocation.equals(other.m_regionLocation);
}
} }

View File

@ -116,6 +116,18 @@ public class RegionPlan implements Comparable<RegionPlan> {
return getRegionName().compareTo(o.getRegionName()); return getRegionName().compareTo(o.getRegionName());
} }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
RegionPlan other = (RegionPlan) obj;
return compareTo(other) == 0;
}
@Override @Override
public String toString() { public String toString() {
return "hri=" + this.hri.getRegionNameAsString() + ", src=" + return "hri=" + this.hri.getRegionNameAsString() + ", src=" +

View File

@ -174,6 +174,11 @@ public class CompactionRequest implements Comparable<CompactionRequest>,
return this.hashCode() - request.hashCode(); return this.hashCode() - request.hashCode();
} }
@Override
public boolean equals(Object obj) {
return (this == obj);
}
/** Gets the HRegion for the request */ /** Gets the HRegion for the request */
public HRegion getHRegion() { public HRegion getHRegion() {
return r; return r;