Package org.instancio.util
Class NumberUtils
- java.lang.Object
-
- org.instancio.util.NumberUtils
-
public final class NumberUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Number & Comparable<T>>
TcalculateNewMax(T curMax, T newMin, int percentage)
Calculate a new maximum given the new minimum.static <T extends Number & Comparable<T>>
TcalculateNewMin(T curMin, T newMax, int percentage)
Calculate a new minimum given the new maximum.static <T extends Number>
Function<Long,T>getLongConverter(Class<?> klass)
static <T extends Number & Comparable<T>>
TgetMaxValue(Class<?> klass)
static <T extends Number & Comparable<T>>
TgetMinValue(Class<?> klass)
-
-
-
Method Detail
-
getMinValue
public static <T extends Number & Comparable<T>> T getMinValue(Class<?> klass)
-
getMaxValue
public static <T extends Number & Comparable<T>> T getMaxValue(Class<?> klass)
-
getLongConverter
public static <T extends Number> Function<Long,T> getLongConverter(Class<?> klass)
-
calculateNewMin
public static <T extends Number & Comparable<T>> T calculateNewMin(T curMin, T newMax, int percentage)
Calculate a new minimum given the new maximum.If the new maximum is less than or equal to the current minimum, returns a new minimum value that is lower than the nex maximum by the specified percentage. Otherwise, returns the current minimum.
- Type Parameters:
T
- number type- Parameters:
curMin
- current minimumnewMax
- new maximumpercentage
- to adjust by- Returns:
- new minimum if current is greater than or equal to current maximum
-
calculateNewMax
public static <T extends Number & Comparable<T>> T calculateNewMax(T curMax, T newMin, int percentage)
Calculate a new maximum given the new minimum.If the new minimum is greater than or equal to the current maximum, returns a new maximum value that is higher than the new minimum by the specified percentage. Otherwise, returns the current maximum.
- Type Parameters:
T
- number type- Parameters:
curMax
- current maximumnewMin
- new minimumpercentage
- to adjust by- Returns:
- new maximum if current is lower than or equal to current minimum
-
-