[
https://issues.apache.org/jira/browse/LANG-1674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Baljit Singh updated LANG-1674:
-------------------------------
Description:
The constructors for {{org.apache.commons.lang3.Range}} don't play nicely with
abstract classes. Example:
static abstract class AbstractComparable implements
Comparable<AbstractComparable> {
@Override
public int compareTo(AbstractComparable o) {
throw new UnsupportedOperationException();
}
}
static class DerivedA extends AbstractComparable {
}
static class DerivedB extends AbstractComparable {
}
// valid, but reasonable since AbstractComparable is the common parent
static final Range<AbstractComparable> RANGE_MIXED = Range.between(new
DerivedA(), new DerivedB());
// valid, but unreasonable to force usage of parent class
static final Range<AbstractComparable> RANGE_SAME = Range.between(new
DerivedA(), new DerivedA());
// compiler error
static final Range<DerivedA> RANGE_A = Range.between(new DerivedA(), new
DerivedA());
was:The constructors for {{org.apache.commons.lang3.Range don't play with
abstract classes.}}
> Range construction with abstract/derived classes
> ------------------------------------------------
>
> Key: LANG-1674
> URL: https://issues.apache.org/jira/browse/LANG-1674
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Baljit Singh
> Priority: Minor
>
> The constructors for {{org.apache.commons.lang3.Range}} don't play nicely
> with abstract classes. Example:
> static abstract class AbstractComparable implements
> Comparable<AbstractComparable> {
> @Override
> public int compareTo(AbstractComparable o) {
> throw new UnsupportedOperationException();
> }
> }
> static class DerivedA extends AbstractComparable {
> }
> static class DerivedB extends AbstractComparable {
> }
> // valid, but reasonable since AbstractComparable is the common parent
> static final Range<AbstractComparable> RANGE_MIXED = Range.between(new
> DerivedA(), new DerivedB());
> // valid, but unreasonable to force usage of parent class
> static final Range<AbstractComparable> RANGE_SAME = Range.between(new
> DerivedA(), new DerivedA());
> // compiler error
> static final Range<DerivedA> RANGE_A = Range.between(new DerivedA(), new
> DerivedA());
--
This message was sent by Atlassian Jira
(v8.3.4#803005)