Package io.servicetalk.utils.internal
Class NumberUtils
java.lang.Object
io.servicetalk.utils.internal.NumberUtils
Helper utilities for
Number
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic int
ensureNonNegative
(int value, String name) Ensures the int is non-negative.static long
ensureNonNegative
(long value, String name) Ensures the long is non-negative.static int
ensurePositive
(int value, String name) Ensures the int is positive, excluding zero.static long
ensurePositive
(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
-