commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wooten <mwooten....@gmail.com>
Subject Re: [LANG] Suggestions For New Features
Date Thu, 20 Aug 2009 12:23:12 GMT
On Tue, Aug 11, 2009 at 8:31 AM, James Carman <james@carmanconsulting.com>wrote:

> On Tue, Aug 11, 2009 at 2:09 AM, Henri Yandell<flamefew@gmail.com> wrote:
> >>   - sizeInRange(int minSize, int maxSize, String string, String message)
> >>      - throws an IllegalArgumentException stating (message + value) when
> >>      the length of the provided string does not fall between the minimum
> and
> >>      maximum size values (inclusive).
> >
> > I like 'between' more than 'inRange'.
> >
> > I think a simpler API would be (ignoring the String message overloads):
> >
> > between(Comparable<T> start, Comparable<T> end, Comparable<T>
value)
> > between(int minSize, int maxSize, int value)
>
> >> How would you account for the "inclusiveness" of both sides?
>

I was assuming I would use the fact that compareTo() returns 0 for the case
of equality. My original assumption was the test would be as simple as
((value.compareTo(start) >= 0) && (value.compareTo(end) <= 0)).  However, as
the documentation for Comparable states, compareTo()'s 0 return may not be
equivalent to equals(), so feel free to debate how this would be
implemented. It may just be the case that the behavior be documented in the
API.

Additional thoughts?


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message