@@ -135,20 +135,18 @@ public static Duration nonNegative(Duration arg) {
135135 return arg ;
136136 }
137137
138- public static int nonNegative (String argName , Integer number ) {
139- if (number == null ) {
140- throw new IllegalArgumentException (String .format (ARG_MUST_BE_SET , argName ));
141- }
138+ public static int nonNegative (String argName , int number ) {
142139 if (number < 0 ) {
143140 throw new IllegalArgumentException (argName + " cannot be less than 0" );
144141 }
145142 return number ;
146143 }
147144
148- public static int positive (String argName , Integer number , String message ) {
149- if (number == null ) {
150- throw new IllegalArgumentException (String .format (ARG_MUST_BE_SET , argName ));
151- }
145+ public static int positive (String argName , int number ) {
146+ return positive (argName , number , null );
147+ }
148+
149+ public static int positive (String argName , int number , String message ) {
152150 if (number <= 0 ) {
153151 if (message == null ) {
154152 throw new IllegalArgumentException (argName + " must be greater than 0" );
@@ -159,6 +157,10 @@ public static int positive(String argName, Integer number, String message) {
159157 return number ;
160158 }
161159
160+ public static double positive (String argName , double number ) {
161+ return positive (argName , number , null );
162+ }
163+
162164 public static double positive (String argName , double number , String message ) {
163165 if (number <= 0 ) {
164166 if (message == null ) {
@@ -170,32 +172,19 @@ public static double positive(String argName, double number, String message) {
170172 return number ;
171173 }
172174
173- public static double positive (String argName , double number ) {
174- return positive (argName , number , null );
175- }
176-
177- public static int positive (String argName , Integer number ) {
178- return positive (argName , number , null );
179- }
180-
181- public static IntChecker argument (String argName , Integer number ) {
182- return new IntChecker (argName , number );
175+ public static IntChecker argument (int number ) {
176+ return new IntChecker (number );
183177 }
184178
185179 public static class IntChecker {
186180
187- private final String argName ;
188- private final Integer number ;
181+ private final int number ;
189182
190- IntChecker (String argName , Integer number ) {
191- this .argName = argName ;
183+ IntChecker (int number ) {
192184 this .number = number ;
193185 }
194186
195187 public int greaterThan (int max , String message ) {
196- if (number == null ) {
197- throw new IllegalArgumentException (String .format (ARG_MUST_BE_SET , argName ));
198- }
199188 if (number <= max ) {
200189 throw new IllegalArgumentException (message );
201190 }
0 commit comments