[jira] Created: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

AD_LB (Jira)
LeftOf/RightOfNumber in Range convenience methods necessary
-----------------------------------------------------------

                 Key: LANG-386
                 URL: https://issues.apache.org/jira/browse/LANG-386
             Project: Commons Lang
          Issue Type: New Feature
    Affects Versions: 2.3
            Reporter: Michael


I've using Ranges recently and found then insufficent in methods.
I cand check if my numbers is in the Range or not but I cant check on which side of the Range it is.
This is my idea:

Range range = new Range(0,5);

boolean outsided = range.leftOfInteger(-5);
outsided equals true
boolean outsided = range.leftOfInteger(5);
outsided equals tfase

same applies for rightOf

another convenience method would be:

create 3 final static int field:

Range.LEFT_OF = -1;
Range.INSIDE = 0;
Range.RIGHT_OF = 1;

range.positionOfInteger(-2)  returns LEFT_OF
and so forth

it is some refactoring of contains and the upper methods.

it would increase functionality

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/LANG-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556308#action_12556308 ]

Henri Yandell commented on LANG-386:
------------------------------------

Sounds interesting. Naming feels a little tricky; in the above you've got your results back to front (for my reading of the name). ie:

false = range.leftOfInteger(-5);
true = range.leftOfInteger(5);

ie) Range is left of Integer.

Also possibly should use lessThan/greaterThan semantics rather than left/right.

The 3 static int field and positionOfInteger suggests the style of Comparable interface.

As long as we maintain the existing API, I'm all for adding methods to define greater/lesser and a compareTo style method. Patches welcome :)

> LeftOf/RightOfNumber in Range convenience methods necessary
> -----------------------------------------------------------
>
>                 Key: LANG-386
>                 URL: https://issues.apache.org/jira/browse/LANG-386
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.3
>            Reporter: Michael
>
> I've using Ranges recently and found then insufficent in methods.
> I cand check if my numbers is in the Range or not but I cant check on which side of the Range it is.
> This is my idea:
> Range range = new Range(0,5);
> boolean outsided = range.leftOfInteger(-5);
> outsided equals true
> boolean outsided = range.leftOfInteger(5);
> outsided equals tfase
> same applies for rightOf
> another convenience method would be:
> create 3 final static int field:
> Range.LEFT_OF = -1;
> Range.INSIDE = 0;
> Range.RIGHT_OF = 1;
> range.positionOfInteger(-2)  returns LEFT_OF
> and so forth
> it is some refactoring of contains and the upper methods.
> it would increase functionality

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

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

     [ https://issues.apache.org/jira/browse/LANG-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-386:
-------------------------------

    Fix Version/s: 3.0

> LeftOf/RightOfNumber in Range convenience methods necessary
> -----------------------------------------------------------
>
>                 Key: LANG-386
>                 URL: https://issues.apache.org/jira/browse/LANG-386
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.3
>            Reporter: Michael
>             Fix For: 3.0
>
>
> I've using Ranges recently and found then insufficent in methods.
> I cand check if my numbers is in the Range or not but I cant check on which side of the Range it is.
> This is my idea:
> Range range = new Range(0,5);
> boolean outsided = range.leftOfInteger(-5);
> outsided equals true
> boolean outsided = range.leftOfInteger(5);
> outsided equals tfase
> same applies for rightOf
> another convenience method would be:
> create 3 final static int field:
> Range.LEFT_OF = -1;
> Range.INSIDE = 0;
> Range.RIGHT_OF = 1;
> range.positionOfInteger(-2)  returns LEFT_OF
> and so forth
> it is some refactoring of contains and the upper methods.
> it would increase functionality

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/LANG-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774576#action_12774576 ]

Henri Yandell commented on LANG-386:
------------------------------------

elementBefore and elementAfter methods have been added as a part of LANG-551.

No positionOf type method as yet.

> LeftOf/RightOfNumber in Range convenience methods necessary
> -----------------------------------------------------------
>
>                 Key: LANG-386
>                 URL: https://issues.apache.org/jira/browse/LANG-386
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.3
>            Reporter: Michael Osipov
>             Fix For: 3.0
>
>
> I've using Ranges recently and found then insufficent in methods.
> I cand check if my numbers is in the Range or not but I cant check on which side of the Range it is.
> This is my idea:
> Range range = new Range(0,5);
> boolean outsided = range.leftOfInteger(-5);
> outsided equals true
> boolean outsided = range.leftOfInteger(5);
> outsided equals tfase
> same applies for rightOf
> another convenience method would be:
> create 3 final static int field:
> Range.LEFT_OF = -1;
> Range.INSIDE = 0;
> Range.RIGHT_OF = 1;
> range.positionOfInteger(-2)  returns LEFT_OF
> and so forth
> it is some refactoring of contains and the upper methods.
> it would increase functionality

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

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (LANG-386) LeftOf/RightOfNumber in Range convenience methods necessary

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

     [ https://issues.apache.org/jira/browse/LANG-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-386.
------------------------------

    Resolution: Fixed

positionOfInteger added to the new generic Range class as elementCompareTo.

> LeftOf/RightOfNumber in Range convenience methods necessary
> -----------------------------------------------------------
>
>                 Key: LANG-386
>                 URL: https://issues.apache.org/jira/browse/LANG-386
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.3
>            Reporter: Michael Osipov
>             Fix For: 3.0
>
>
> I've using Ranges recently and found then insufficent in methods.
> I cand check if my numbers is in the Range or not but I cant check on which side of the Range it is.
> This is my idea:
> Range range = new Range(0,5);
> boolean outsided = range.leftOfInteger(-5);
> outsided equals true
> boolean outsided = range.leftOfInteger(5);
> outsided equals tfase
> same applies for rightOf
> another convenience method would be:
> create 3 final static int field:
> Range.LEFT_OF = -1;
> Range.INSIDE = 0;
> Range.RIGHT_OF = 1;
> range.positionOfInteger(-2)  returns LEFT_OF
> and so forth
> it is some refactoring of contains and the upper methods.
> it would increase functionality

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