[
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:
{quote}
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<DerivedA> RANGE_B = Range.is(new DerivedB());
{quote}
was:
The constructors for {{org.apache.commons.lang3.Range}} don't play nicely with
abstract classes. Example:
{quote}static abstract class AbstractComparable implements
Comparable<AbstractComparable>
Unknown macro: \{ @Override public int compareTo(AbstractComparable o) Unknown
macro}
}
static class DerivedA extends AbstractComparable {
}
static 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<DerivedA> RANGE_B = Range.is(new DerivedB());{quote}
> 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:
> {quote}
> 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<DerivedA> RANGE_B = Range.is(new DerivedB());
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)