Package io.servicetalk.utils.internal
Class NumberUtils
java.lang.Object
io.servicetalk.utils.internal.NumberUtils
Helper utilities for
Numbers.-
Method Summary
Modifier and TypeMethodDescriptionstatic intensureNonNegative(int value, String name) Ensures the int is non-negative.static longensureNonNegative(long value, String name) Ensures the long is non-negative.static intensurePositive(int value, String name) Ensures the int is positive, excluding zero.static longensurePositive(long value, String name) Ensures the long is positive, excluding zero.
-
Method Details
-
ensurePositive
Ensures the int is positive, excluding zero.- Parameters:
value- the int value to validatename- name of the variable- Returns:
- the passed value if all checks pass
- Throws:
IllegalArgumentException- if the passed int is not greater than zero
-
ensurePositive
Ensures the long is positive, excluding zero.- Parameters:
value- the long value to validatename- name of the variable- Returns:
- the passed value if all checks pass
- Throws:
IllegalArgumentException- if the passed long is not greater than zero
-
ensureNonNegative
Ensures the int is non-negative.- Parameters:
value- the int value to validatename- name of the variable- Returns:
- the passed value if all checks pass
- Throws:
IllegalArgumentException- if the passed int is less than zero
-
ensureNonNegative
Ensures the long is non-negative.- Parameters:
value- the long value to validatename- name of the variable- Returns:
- the passed value if all checks pass
- Throws:
IllegalArgumentException- if the passed long is less than zero
-