Lines Matching refs:value

195      * Ensures that that the argument numeric value is non-negative.
197 * @param value a numeric int value
199 * @return the validated numeric value
200 * @throws IllegalArgumentException if {@code value} was negative
202 public static @IntRange(from = 0) int checkArgumentNonnegative(final int value,
204 if (value < 0) {
208 return value;
212 * Ensures that that the argument numeric value is non-negative.
214 * @param value a numeric int value
216 * @return the validated numeric value
217 * @throws IllegalArgumentException if {@code value} was negative
219 public static @IntRange(from = 0) int checkArgumentNonnegative(final int value) {
220 if (value < 0) {
224 return value;
228 * Ensures that that the argument numeric value is non-negative.
230 * @param value a numeric long value
231 * @return the validated numeric value
232 * @throws IllegalArgumentException if {@code value} was negative
234 public static long checkArgumentNonnegative(final long value) {
235 if (value < 0) {
239 return value;
243 * Ensures that that the argument numeric value is non-negative.
245 * @param value a numeric long value
247 * @return the validated numeric value
248 * @throws IllegalArgumentException if {@code value} was negative
250 public static long checkArgumentNonnegative(final long value, final String errorMessage) {
251 if (value < 0) {
255 return value;
259 * Ensures that that the argument numeric value is positive.
261 * @param value a numeric int value
263 * @return the validated numeric value
264 * @throws IllegalArgumentException if {@code value} was not positive
266 public static int checkArgumentPositive(final int value, final String errorMessage) {
267 if (value <= 0) {
271 return value;
275 * Ensures that the argument floating point value is a finite number.
280 * @param value a floating point value
283 * @return the validated floating point value
285 * @throws IllegalArgumentException if {@code value} was not finite
287 public static float checkArgumentFinite(final float value, final String valueName) {
288 if (Float.isNaN(value)) {
290 } else if (Float.isInfinite(value)) {
294 return value;
298 * Ensures that the argument floating point value is within the inclusive range.
303 * @param value a floating point value
308 * @return the validated floating point value
310 * @throws IllegalArgumentException if {@code value} was not within the range
312 public static float checkArgumentInRange(float value, float lower, float upper,
314 if (Float.isNaN(value)) {
316 } else if (value < lower) {
320 } else if (value > upper) {
326 return value;
330 * Ensures that the argument int value is within the inclusive range.
332 * @param value a int value
337 * @return the validated int value
339 * @throws IllegalArgumentException if {@code value} was not within the range
341 public static int checkArgumentInRange(int value, int lower, int upper,
343 if (value < lower) {
347 } else if (value > upper) {
353 return value;
357 * Ensures that the argument long value is within the inclusive range.
359 * @param value a long value
364 * @return the validated long value
366 * @throws IllegalArgumentException if {@code value} was not within the range
368 public static long checkArgumentInRange(long value, long lower, long upper,
370 if (value < lower) {
374 } else if (value > upper) {
380 return value;
386 * @param value an array of boxed objects
391 * @throws NullPointerException if the {@code value} or any of its elements were {@code null}
393 public static <T> T[] checkArrayElementsNotNull(final T[] value, final String valueName) {
394 if (value == null) {
398 for (int i = 0; i < value.length; ++i) {
399 if (value[i] == null) {
405 return value;
412 * @param value a {@link Collection} of boxed objects
417 * @throws NullPointerException if the {@code value} or any of its elements were {@code null}
420 final C value, final String valueName) {
421 if (value == null) {
426 for (T elem : value) {
434 return value;
440 * @param value a {@link Collection} of boxed elements.
445 * @throws NullPointerException if the {@code value} was {@code null}
446 * @throws IllegalArgumentException if the {@code value} was empty
448 public static <T> Collection<T> checkCollectionNotEmpty(final Collection<T> value,
450 if (value == null) {
453 if (value.isEmpty()) {
456 return value;
465 * @param value a floating point array of values
470 * @return the validated floating point value
472 * @throws IllegalArgumentException if any of the elements in {@code value} were out of range
473 * @throws NullPointerException if the {@code value} was {@code null}
475 public static float[] checkArrayElementsInRange(float[] value, float lower, float upper,
477 checkNotNull(value, valueName + " must not be null");
479 for (int i = 0; i < value.length; ++i) {
480 float v = value[i];
495 return value;