Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
The constructors for org.apache.commons.lang3.Range don't play nicely with abstract/derived classes. Example:
abstract class AbstractComparable implements Comparable<AbstractComparable> {
@Override public int compareTo(AbstractComparable o) {}
}class DerivedA extends AbstractComparable {}
class DerivedB extends AbstractComparable {}
// compiles, and reasonable since AbstractComparable is the common parent
static final Range<AbstractComparable> RANGE_MIXED = Range.between(new DerivedA(), new DerivedB());// compiles, but unreasonable to force usage of parent class
static final Range<AbstractComparable> RANGE_SAME_CLASS = Range.between(new DerivedA(), new DerivedA());// compiler error
static final Range<DerivedA> RANGE_A = Range.between(new DerivedA(), new DerivedA());// compiler error
static final Range<DerivedB> RANGE_B = Range.is(new DerivedB());