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

13 messages Options
Embed this post
Permalink
JIRA jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink

     [ 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.

JIRA jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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 jira@apache.org

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@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.