You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2009/11/05 09:35:33 UTC

[jira] Created: (LANG-551) Replace Range classes with generic version

Replace Range classes with generic version
------------------------------------------

                 Key: LANG-551
                 URL: https://issues.apache.org/jira/browse/LANG-551
             Project: Commons Lang
          Issue Type: Task
            Reporter: Henri Yandell
             Fix For: 3.0
         Attachments: Range.java

Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774264#action_12774264 ] 

Sebb commented on LANG-551:
---------------------------

Code sometimes uses "this.getMinimum()" and sometimes "getMinimum()". Should be consistent.

But why use the getter at all? Is the class intended to be subclassed and the getters overridden, but not all the methods that use the getters?

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774230#action_12774230 ] 

Henri Yandell commented on LANG-551:
------------------------------------

svn ci -m "Committing work in progress version of a new Range class to replace the math.*Range classes as discussed in LANG-551" src
Adding         src/java/org/apache/commons/lang/Range.java
Adding         src/test/org/apache/commons/lang/RangeTest.java
Transmitting file data ..
Committed revision 833308.

Needs more test work, which I'll plod through. Wanted to get it into wider circulation.

Action item for end of this issue is to remove the old classes.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12777422#action_12777422 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Per LANG-386, an elementCompareTo method has been added.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791878#action_12791878 ] 

Henri Yandell commented on LANG-551:
------------------------------------

overlapsRange staying the same makes sense. Real issue is before/after.

Range[6-10] - elementBefore(5)? = true.
Range[Not 6-10] - elementBefore(5)? = ?

The range is -inf to 5, and 11 to inf. The notion of before and after with the two ranges doesn't make sense, so leaving it on the 6-10 seems the best thing to do. People can always ask if the range is inverted in their code if they're trying to do something weird here.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>          Components: lang.math.*
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12777808#action_12777808 ] 

Henri Yandell commented on LANG-551:
------------------------------------

CharRange is a close match, except for the negated/inverted attribute. 

This could be added to Range, though might be a little odd.

    public boolean elementBefore(T element) {
    public boolean elementAfter(T element) {
    public int elementCompareTo(T element) { [based on the before]
    public boolean overlapsRange(Range<T> range) {

I think these would remain the same. 


    public boolean contains(T element) {
    public boolean containsRange(Range<T> range) {

These would be inverted.

Would also move from constructors to static builder methods per CharRange.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793527#action_12793527 ] 

Henri Yandell commented on LANG-551:
------------------------------------

I've tried a few times now to rewrite Range to support 'inverted' and thus be a CharRange replacement. It doesn't feel right.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>          Components: lang.math.*
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12773996#action_12773996 ] 

Sebb commented on LANG-551:
---------------------------

Looks OK.

Minor points:
+ Private instance variables could be made final.
+ should either use this.getMinimum() or this.minimum (ditto maximum) throughout. Preferably the latter.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774275#action_12774275 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Don't know yet - I wasn't confident of what the class would end up looking like as the NumberRanges were refactored in. Still might be that the Serializable, Comparable and CharRange questions end up with a subclass. 

I've added a TODO to make sure final/field-usage is covered.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774231#action_12774231 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Something to consider - should CharRange also be folded in?

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791875#action_12791875 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Now uses static build methods, so part way to CharRange. Need to figure out the negated/inverted concept still.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>          Components: lang.math.*
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774266#action_12774266 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Sorry - missed one of the unnecessary this statements on this.getMin.

The methods aren't final, so I would expect to be able to extend the class and have getMinimum called everywhere instead of this.minimum.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774223#action_12774223 ] 

Henri Yandell commented on LANG-551:
------------------------------------

Thanks Sebb. Both minor points fixed.

I'll work on the test for this - obviously wanting to make sure I cover all of the old use cases and get some new ones in.

Two open questions I have are:

1) Should it be Serializable
2) How do I do the following:

The class itself will be a generic on <T>, nothing special. I then want a particular pair of the constructors to only allow T's that extend Comparable. Anyone have any ideas how to do that?

Do I need to setup a subclass for those two constructors that are generic on <T extends Comparable<? super T>>, should I rely on runtime checking or is there a better way?

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12777423#action_12777423 ] 

Henri Yandell commented on LANG-551:
------------------------------------

svn ci -m "Removing old Range classes per LANG-551. New lang.Range class replaces these"
Deleting       src/java/org/apache/commons/lang/math/DoubleRange.java
Deleting       src/java/org/apache/commons/lang/math/FloatRange.java
Deleting       src/java/org/apache/commons/lang/math/IntRange.java
Deleting       src/java/org/apache/commons/lang/math/LongRange.java
Deleting       src/java/org/apache/commons/lang/math/NumberRange.java
Deleting       src/java/org/apache/commons/lang/math/Range.java
Deleting       src/test/org/apache/commons/lang/math/AbstractRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/DoubleRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/FloatRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/IntRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/LongRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/NumberRangeTest.java
Deleting       src/test/org/apache/commons/lang/math/RangeTest.java

Committed revision 835780.


> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-551.
------------------------------

    Resolution: Fixed

svn ci -m "Making class final, switching getMin/Max usage to this.min/max usage. LANG-551"
Sending        src/java/org/apache/commons/lang3/Range.java
Transmitting file data .
Committed revision 893083.


> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>          Components: lang.math.*
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-551) Replace Range classes with generic version

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774268#action_12774268 ] 

Sebb commented on LANG-551:
---------------------------

But is there a use case for extending the class? i.e. why is it not final?

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>            Assignee: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-551) Replace Range classes with generic version

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-551?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-551:
-------------------------------

    Attachment: Range.java

Adding a quick version of a proposed Range.java class for thoughts.

> Replace Range classes with generic version
> ------------------------------------------
>
>                 Key: LANG-551
>                 URL: https://issues.apache.org/jira/browse/LANG-551
>             Project: Commons Lang
>          Issue Type: Task
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>         Attachments: Range.java
>
>
> Possible direction of deleting the math.Range classes and replacing with a Range class based on Comparators.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.