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 doublenonNegative(double value) Check if the specified value is not negative.static doublenonNegative(double value, String message) Check if the specified value is not negative.static intnonNegative(int length) Check if the given integer is negative.static doublepositive(double value) static intpositive(int value) Require the givenvalueto be positive (> 0).static longpositive(long value) static doubleprobability(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 givenlengthis smaller than zero.
-
positive
Require the givenvalueto be positive (> 0).- Parameters:
value- the value to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the givenvalueis 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- ifpis not a valid probability.
-