java.lang.Object
io.jenetics.internal.util.Requires
Some helper methods for creating hash codes and comparing values.
- Since:
- 1.0
- Version:
- 5.2
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
nonNegative
(double value) Check if the specified value is not negative.static double
nonNegative
(double value, String message) Check if the specified value is not negative.static int
nonNegative
(int length) Check if the given integer is negative.static double
positive
(double value) static int
positive
(int value) Require the givenvalue
to be positive (> 0).static long
positive
(long value) static double
probability
(double p) Check if the given double value is within the closed range[0, 1]
.
-
Method Details
-
nonNegative
Check if the specified value is not negative.- Parameters:
value
- the value to check.message
- the exception message.- Returns:
- the given value.
- Throws:
IllegalArgumentException
- ifvalue < 0
.
-
nonNegative
Check if the specified value is not negative.- Parameters:
value
- the value to check.- Returns:
- the given value.
- Throws:
IllegalArgumentException
- ifvalue < 0
.
-
nonNegative
Check if the given integer is negative.- Parameters:
length
- the value to check.- Returns:
- the length input
- Throws:
NegativeArraySizeException
- if the givenlength
is smaller than zero.
-
positive
Require the givenvalue
to be positive (> 0).- Parameters:
value
- the value to check- Returns:
- the given value
- Throws:
IllegalArgumentException
- if the givenvalue
is smaller than or equal zero.
-
positive
-
positive
-
probability
Check if the given double value is within the closed range[0, 1]
.- Parameters:
p
- the probability to check.- Returns:
- p if it is a valid probability.
- Throws:
IllegalArgumentException
- ifp
is not a valid probability.
-