On Tue, Aug 11, 2009 at 8:31 AM, James Carman <[email protected]>wrote:

> On Tue, Aug 11, 2009 at 2:09 AM, Henri Yandell<[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to