Make ObjectId.compareTo final
Since equals() is now final and does not permit being overridden, we should do the same thing with compareTo() to prevent different subclasses from having different ordering behaviors. This could lead to the same mess that we had with different equals() behaviors. Change-Id: I35a849b6efccee5fe74cc5788a3566a1516004b7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
5adcd708e4
commit
1c2290c8d6
|
@ -113,7 +113,7 @@ public final int getFirstByte() {
|
|||
* @return < 0 if this id comes before other; 0 if this id is equal to
|
||||
* other; > 0 if this id comes after other.
|
||||
*/
|
||||
public int compareTo(final AnyObjectId other) {
|
||||
public final int compareTo(final AnyObjectId other) {
|
||||
if (this == other)
|
||||
return 0;
|
||||
|
||||
|
@ -138,7 +138,7 @@ public int compareTo(final AnyObjectId other) {
|
|||
return NB.compareUInt32(w5, other.w5);
|
||||
}
|
||||
|
||||
public int compareTo(final Object other) {
|
||||
public final int compareTo(final Object other) {
|
||||
return compareTo(((AnyObjectId) other));
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public int compareTo(final Object other) {
|
|||
* @return a negative integer, zero, or a positive integer as this object is
|
||||
* less than, equal to, or greater than the specified object.
|
||||
*/
|
||||
public int compareTo(final byte[] bs, final int p) {
|
||||
public final int compareTo(final byte[] bs, final int p) {
|
||||
int cmp;
|
||||
|
||||
cmp = NB.compareUInt32(w1, NB.decodeInt32(bs, p));
|
||||
|
@ -186,7 +186,7 @@ public int compareTo(final byte[] bs, final int p) {
|
|||
* @return a negative integer, zero, or a positive integer as this object is
|
||||
* less than, equal to, or greater than the specified object.
|
||||
*/
|
||||
public int compareTo(final int[] bs, final int p) {
|
||||
public final int compareTo(final int[] bs, final int p) {
|
||||
int cmp;
|
||||
|
||||
cmp = NB.compareUInt32(w1, bs[p]);
|
||||
|
|
Loading…
Reference in New Issue