diff options
author | Roberto Tyley <roberto.tyley@gmail.com> | 2013-05-16 15:44:41 +0100 |
---|---|---|
committer | Roberto Tyley <roberto.tyley@gmail.com> | 2013-05-16 15:44:41 +0100 |
commit | e7fc19fc0c8099a7076d883798d3439403bdbb6e (patch) | |
tree | c3c15e1a0237c6084b607cff20d1c84cc4f19ded | |
parent | c93a59330249677cd990820b59558a39f747009f (diff) | |
download | jgit-e7fc19fc0c8099a7076d883798d3439403bdbb6e.tar.gz jgit-e7fc19fc0c8099a7076d883798d3439403bdbb6e.zip |
Fix AnyObjectId's generic type declaration of Comparable
If you look at any implementation of Comparable in the JDK, you'll see
that the type parameter for Comparable is supposed to be the type of
the implementing class:
http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html
The current type signature of Comparable<Object> is pretty awful, at the
very least because you can not, in fact, successfully compare
AnyObjectId with any random subclass of Object. It also causes problems
with type-inference and the scala.math.Ordering trait in Scala.
In order to compile, this change *does* require removing the
AnyObjectId.ompareTo(Object) method - which actually only ever cast
to AnyObjectId in any case. Nothing in the JGit test suite requires this
method, but it might constitute a breaking API change, so it would be
best if it can be added in time for JGit 3.0.
Change-Id: I3b549a5519ccd6785f98e444da76d2363bcbe41a
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java index e408c79a3b..9db4a61c69 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java @@ -57,7 +57,7 @@ import org.eclipse.jgit.util.NB; * with this instance can alter at any time, if this instance is modified to * represent a different object name. */ -public abstract class AnyObjectId implements Comparable<Object> { +public abstract class AnyObjectId implements Comparable<AnyObjectId> { /** * Compare to object identifier byte sequences for equality. @@ -184,10 +184,6 @@ public abstract class AnyObjectId implements Comparable<Object> { return NB.compareUInt32(w5, other.w5); } - public final int compareTo(final Object other) { - return compareTo(((AnyObjectId) other)); - } - /** * Compare this ObjectId to a network-byte-order ObjectId. * |