[
https://issues.apache.org/jira/browse/LANG-1674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved LANG-1674.
-----------------------------------
Fix Version/s: 3.13.0
Resolution: Fixed
> 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
> Fix For: 3.13.0
>
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> The constructors for {{org.apache.commons.lang3.Range}} don't play nicely
> with abstract/derived 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<DerivedB> RANGE_B = Range.is(new DerivedB());
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)