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:
https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Preconditions.java

See Commons Lang Validate:
https://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/Validate.html

See OpenGamma ArgChecker:
http://opengamma.github.io/StrataDocs/apidocs/com/opengamma/strata/collect/ArgChecker.html
https://github.com/OpenGamma/Strata/blob/master/modules/collect/src/main/java/com/opengamma/strata/collect/ArgChecker.java

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.

Stephen



On 29 September 2015 at 09:44, Paul Sandoz <paul.san...@oracle.com> wrote:
>
>> On 29 Sep 2015, at 06:48, John Rose <john.r.r...@oracle.com> wrote:
>>
>> On Sep 28, 2015, at 5:10 PM, Joseph D. Darcy <joe.da...@oracle.com 
>> <mailto:joe.da...@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>
>
> Paul.

Reply via email to