Package dev.prozilla.pine.common.util
Class Numbers
java.lang.Object
dev.prozilla.pine.common.util.Numbers
Static utility methods for checking certain conditions before operation on numbers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float
requirePositive
(float number) Checks that the given number is a positive number and throws anInvalidNumberException
if it is not.static float
requirePositive
(float number, String message) Checks that the given number is a positive number and throws a customizedInvalidNumberException
if it is not.static int
requirePositive
(int number) Checks that the given number is a positive number and throws anInvalidNumberException
if it is not.static int
requirePositive
(int number, String message) Checks that the given number is a positive number and throws a customizedInvalidNumberException
if it is not.
-
Constructor Details
-
Numbers
public Numbers()
-
-
Method Details
-
requirePositive
Checks that the given number is a positive number and throws anInvalidNumberException
if it is not.- Parameters:
number
- The number to check- Returns:
number
if it is positive.- Throws:
InvalidNumberException
- Ifnumber
is not positive.
-
requirePositive
Checks that the given number is a positive number and throws a customizedInvalidNumberException
if it is not.- Parameters:
number
- The number to checkmessage
- The message to be used in the event that anInvalidNumberException
is thrown- Returns:
number
if it is positive.- Throws:
InvalidNumberException
- Ifnumber
is not positive.
-
requirePositive
Checks that the given number is a positive number and throws anInvalidNumberException
if it is not.- Parameters:
number
- The number to check- Returns:
number
if it is positive.- Throws:
InvalidNumberException
- Ifnumber
is not positive.
-
requirePositive
Checks that the given number is a positive number and throws a customizedInvalidNumberException
if it is not.- Parameters:
number
- The number to checkmessage
- The message to be used in the event that anInvalidNumberException
is thrown- Returns:
number
if it is positive.- Throws:
InvalidNumberException
- Ifnumber
is not positive.
-