The Joda AbstractInstant interface extends the original Comparable type instead of Comparable<AbstractInstant> , which seems to violate the best Java examples . In particular, this means that I cannot use DateTime to parameterize such a class:
class Foo<T extends Comparable<? super T>> { public int ct(T a, T b) { return a.compareTo(b); } }
It was my understanding that this class was absolutely right (it certainly works with Double, etc.). To make it work with DateTime, I put my own code with a raw type and suppressed the warnings:
@SuppressWarnings("unchecked") class Foo<T extends Comparable> { public int ct(T a, T b) { return a.compareTo(b); } }
There is a related question that offers a workaround (wrapping DateTime in another class for comparison purposes), but I don't understand why this should be necessary. Then my question is:
- Does anyone know why Joda extends raw type or
- Is this a mistake I have to tell the library developers?
java jodatime
Alice purcell
source share