@@ -135,20 +135,18 @@ public static Duration nonNegative(Duration arg) {
135
135
return arg ;
136
136
}
137
137
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 ) {
142
139
if (number < 0 ) {
143
140
throw new IllegalArgumentException (argName + " cannot be less than 0" );
144
141
}
145
142
return number ;
146
143
}
147
144
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 ) {
152
150
if (number <= 0 ) {
153
151
if (message == null ) {
154
152
throw new IllegalArgumentException (argName + " must be greater than 0" );
@@ -159,6 +157,10 @@ public static int positive(String argName, Integer number, String message) {
159
157
return number ;
160
158
}
161
159
160
+ public static double positive (String argName , double number ) {
161
+ return positive (argName , number , null );
162
+ }
163
+
162
164
public static double positive (String argName , double number , String message ) {
163
165
if (number <= 0 ) {
164
166
if (message == null ) {
@@ -170,32 +172,19 @@ public static double positive(String argName, double number, String message) {
170
172
return number ;
171
173
}
172
174
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 );
183
177
}
184
178
185
179
public static class IntChecker {
186
180
187
- private final String argName ;
188
- private final Integer number ;
181
+ private final int number ;
189
182
190
- IntChecker (String argName , Integer number ) {
191
- this .argName = argName ;
183
+ IntChecker (int number ) {
192
184
this .number = number ;
193
185
}
194
186
195
187
public int greaterThan (int max , String message ) {
196
- if (number == null ) {
197
- throw new IllegalArgumentException (String .format (ARG_MUST_BE_SET , argName ));
198
- }
199
188
if (number <= max ) {
200
189
throw new IllegalArgumentException (message );
201
190
}
0 commit comments