Maybe open the comparators and use a fluent API?
is(42).between(10).and(50) == true
is(10).between(10).and(20) == false
is(10).between(10).and(20).includingLeft() == true
is(50).between(10).and(50) == false
is(50).between(10).and(50).includingRight() == true


Just quick thoughts ...

Jan


> -----Ursprüngliche Nachricht-----
> Von: Gilles [mailto:gil...@harfang.homelinux.org]
> Gesendet: Freitag, 29. Dezember 2017 22:46
> An: dev@commons.apache.org
> Betreff: Re: [commons-lang3] NumberUtils feature
> 
> On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
> > Gilles, thanks for you reply.
> >
> > I will consider your sugestions.
> >
> > So, can i open a issue in jira (apache commons) and implement this
> > feature?
> 
> Better wait for other opinions on the various suggestions, as it
> impacts on which JIRA project you'd open the issue.
> 
> Regards,
> Gilles
> 
> >
> > Thanks.
> >
> > Lucas Carvalho
> >
> >
> >
> > On Fri, Dec 29, 2017 at 12:25 PM, Gilles
> > <gil...@harfang.homelinux.org>
> > wrote:
> >
> >> Hi.
> >>
> >> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
> >>
> >>> I`m sorry,
> >>>
> >>> Now code in "text":
> >>>
> >>> public static boolean between(final int value, final int x, final
> >>> int y) {
> >>>
> >>>    return value >= x && value <= y;
> >>>
> >>> }
> >>>
> >>>
> >>> public static boolean between(final short value, final short x,
> >>> final short
> >>> y) {
> >>>
> >>>    return value >= x && value <= y;
> >>>
> >>> }
> >>>
> >>
> >> To comply with the Java convention, it should probably be
> >> "isBetween".
> >>
> >> Incidently, this also shows a weakness of "Utils" classes: the
> >> "target"
> >> (which would normally be "this") is on the same footing as the other
> >> arguments (the bounds of the interval here).
> >>
> >> Also the naming does not reflect whether bounds are included or not:
> >> usually, one would assume that the left bound is included (>=) but
> >> not the right one (<).
> >>
> >> Then, what about "between(15, 20, 10)"?
> >>
> >> Finally, we should consider whether to continue bloating
> >> "NumberUtils"
> >> in "Lang" or move some of it to the new "Numbers" component.[1]
> >>
> >> Regards,
> >> Gilles
> >>
> >> [1]
> >> https://git1-us-west.apache.org/repos/asf?p=commons-
> numbers.git;a=tre
> >> e
> >>
> >>
> >>>
> >>>
> >>> Obrigado.
> >>>
> >>> Atenciosamente
> >>>
> >>> Lucas Carvalho
> >>>
> >>> *Fone *- 34 9 9903 4621
> >>>
> >>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
> >>> <gil...@harfang.homelinux.org>
> >>> wrote:
> >>>
> >>> Hi.
> >>>>
> >>>> On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:
> >>>>
> >>>> Hello everybody,
> >>>>>
> >>>>> I want know if the feature "between" in NumberUtils lib has be
> >>>>> discussed?
> >>>>> I
> >>>>> use this methods a lot and i would like to share this code in
> >>>>> apache commons.
> >>>>>
> >>>>> Below i share a example:
> >>>>>
> >>>>> [image: Inline image 1]
> >>>>>
> >>>>>
> >>>> All I can see is the above.
> >>>> [Perhaps the image was stripped.]
> >>>>
> >>>> I assume it is code; so, please write it here as "text".
> >>>>
> >>>> Thanks,
> >>>> Gilles
> >>>>
> >>>>
> >>>> Thanks.
> >>>>>
> >>>>> Lucas Carvalho
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to