RFR 8135248: Add utility methods to check indexes and ranges
scolebourne at joda.org
Tue Sep 29 10:57:02 UTC 2015
Just to note that an ideal location for this would be on a new class,
one that has been discussed before, an "argument checker class".
See Guava Preconditions:
See Commons Lang Validate:
See OpenGamma ArgChecker:
This was discussed when Objects.requiresNotNull was discussed IIRC. I
still think it would be a great addition to the JDK (as every project
has something similar). This issue could be the start, although it
would need a few more methods, guided by the examples above.
On 29 September 2015 at 09:44, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>> On 29 Sep 2015, at 06:48, John Rose <john.r.rose at oracle.com> wrote:
>> On Sep 28, 2015, at 5:10 PM, Joseph D. Darcy <joe.darcy at oracle.com <mailto:joe.darcy at oracle.com>> wrote:
>>> Joining this thread late, I think the range checking methods would have a happier life where they are more often found and used if the they live somewhere other than the exception classes.
>>> The class java.util.Objects is not an ideal host for these methods, since they don't deal directly with objects per se, but the scope of Objects could be expanded to include these utilities as well.
>> You have a point, that's probably a better bikeshed.
> No objections :-) I think it’s a better location to find such methods. Moved, and i also tweaked to class doc of Objects to include static methods for “checking certain conditions before operation”.
>> Since the key operation is an integer compare, putting it on Integer (near compare) would also be defensible.
>> (The new factory methods for exceptions make sense on the exceptions themselves, of course.)
> I clarified the exception constructors that access one to two out of band values to say they are included in the exception detail message (without actually specifying the presentation format of that message).
> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8135248-ioobe-check-index-range/webrev/ <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8135248-ioobe-check-index-range/webrev/>
> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8135248-ioobe-check-index-range/specdiff/overview-summary.html <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8135248-ioobe-check-index-range/specdiff/overview-summary.html>
More information about the core-libs-dev