- java.lang.Object
-
- com.speedment.common.invariant.DoubleRangeUtil
-
public final class DoubleRangeUtil extends Object
Utility class for checking invariants ondouble-values.- Since:
- 1.0.3
- Author:
- Emil Forslund
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublerequireEquals(double val, double otherVal)static <E extends RuntimeException>
doublerequireEquals(double val, double otherVal, Function<String,E> exceptionConstructor)static doublerequireInRange(double val, double first, double lastExclusive)static <E extends RuntimeException>
doublerequireInRange(double val, double first, double lastExclusive, Function<String,E> exceptionConstructor)static doublerequireInRangeClosed(double val, double first, double lastInclusive)static <E extends RuntimeException>
doublerequireInRangeClosed(double val, double first, double lastInclusive, Function<String,E> exceptionConstructor)static doublerequireNegative(double val)Returns the given value if it is negative (less than0).static <E extends RuntimeException>
doublerequireNegative(double val, Function<String,E> exceptionConstructor)static doublerequireNonNegative(double val)Returns the given value if it is not negative (greater than or equal to0).static <E extends RuntimeException>
doublerequireNonNegative(double val, Function<String,E> exceptionConstructor)static doublerequireNonPositive(double val)Returns the given value if it is not positive (less than or equal to0).static <E extends RuntimeException>
doublerequireNonPositive(double val, Function<String,E> exceptionConstructor)static doublerequireNonZero(double val)Returns the given value if it is not0.static <E extends RuntimeException>
doublerequireNonZero(double val, Function<String,E> exceptionConstructor)static doublerequireNotEquals(double val, double otherVal)static <E extends RuntimeException>
doublerequireNotEquals(double val, double otherVal, Function<String,E> exceptionConstructor)static doublerequirePositive(double val)Returns the given value if it is positive (greater than0).static <E extends RuntimeException>
doublerequirePositive(double val, Function<String,E> exceptionConstructor)Returns the given value if it is positive.static doublerequireZero(double val)Returns the given value if it is equal to0.static <E extends RuntimeException>
doublerequireZero(double val, Function<String,E> exceptionConstructor)
-
-
-
Method Detail
-
requirePositive
public static double requirePositive(double val)
Returns the given value if it is positive (greater than0).- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is not positive
-
requireNegative
public static double requireNegative(double val)
Returns the given value if it is negative (less than0).- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is not negative
-
requireZero
public static double requireZero(double val)
Returns the given value if it is equal to0.- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is not 0
-
requireNonPositive
public static double requireNonPositive(double val)
Returns the given value if it is not positive (less than or equal to0).- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is positive
-
requireNonNegative
public static double requireNonNegative(double val)
Returns the given value if it is not negative (greater than or equal to0).- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is negative
-
requireNonZero
public static double requireNonZero(double val)
Returns the given value if it is not0.- Parameters:
val- to check- Returns:
- the given value
- Throws:
IllegalArgumentException- if the given value is zero
-
requireEquals
public static double requireEquals(double val, double otherVal)
-
requireNotEquals
public static double requireNotEquals(double val, double otherVal)
-
requireInRange
public static double requireInRange(double val, double first, double lastExclusive)
-
requireInRangeClosed
public static double requireInRangeClosed(double val, double first, double lastInclusive)
-
requirePositive
public static <E extends RuntimeException> double requirePositive(double val, Function<String,E> exceptionConstructor)
Returns the given value if it is positive.- Type Parameters:
E- RuntimeException type- Parameters:
val- to checkexceptionConstructor- to use when throwing exception- Returns:
- the given value
- Throws:
RuntimeException- if the given value is not positive
-
requireNegative
public static <E extends RuntimeException> double requireNegative(double val, Function<String,E> exceptionConstructor)
-
requireZero
public static <E extends RuntimeException> double requireZero(double val, Function<String,E> exceptionConstructor)
-
requireNonPositive
public static <E extends RuntimeException> double requireNonPositive(double val, Function<String,E> exceptionConstructor)
-
requireNonNegative
public static <E extends RuntimeException> double requireNonNegative(double val, Function<String,E> exceptionConstructor)
-
requireNonZero
public static <E extends RuntimeException> double requireNonZero(double val, Function<String,E> exceptionConstructor)
-
requireEquals
public static <E extends RuntimeException> double requireEquals(double val, double otherVal, Function<String,E> exceptionConstructor)
-
requireNotEquals
public static <E extends RuntimeException> double requireNotEquals(double val, double otherVal, Function<String,E> exceptionConstructor)
-
requireInRange
public static <E extends RuntimeException> double requireInRange(double val, double first, double lastExclusive, Function<String,E> exceptionConstructor)
-
requireInRangeClosed
public static <E extends RuntimeException> double requireInRangeClosed(double val, double first, double lastInclusive, Function<String,E> exceptionConstructor)
-
-