Ah, I was going to write about "values" ... glad this was mentioned. With Valhalla working on value classes, it does raise the question if range-checking is particular to Objects. Clearly it won't be once values are introduced.
PS: I am still in favor of using Objects at the time being though just to get something checked-in. Cheers, Paul On Wed, Sep 30, 2015 at 2:34 AM, Peter Levart <peter.lev...@gmail.com> wrote: > > > On 09/29/2015 10:01 PM, Paul Sandoz wrote: > >> >I think it's worth introducing Preconditions class. checkNotNull >>> overloads are equally well suited for Objects as they are for >>> Preconditions, so it's not wrong to have them in both, while checkIndex and >>> friends don't really suit any of the existing classes. If I would have to >>> search for them in among existing classes, Arrays would be the place to >>> look first. List interface the 2nd. IndexOutOfBoundsException wouldn't come >>> to my mind, as Exception(s) are usually not homes for logic, neither would >>> Integer which is to abstract to mentally associate it with array or list >>> index checks. >>> > >>> >> The concern i have is once Preconditions is let loose the scope expands >> with proposals for “just one more method” (there is even the opportunity to >> bike shed over the names checkNotNull or requiresNotNull etc. etc.) I >> don’t want to discuss such additional methods right now otherwise i will >> never make progress with the current set. >> >> A way forward is to initially include Preconditions with*only* the check >> index methods, and in subsequent proposals selectively add more. At the >> moment i am still leaning towards Objects. >> >> Paul. >> >> > I promise I won't discuss any other methods - just checkIndex and friends > (small steps...) > But having them in Objects would be very strange. Indexes are not objects > - they are values. > > > Regards, Peter >