Package org.instancio.util
Class NumberUtils
java.lang.Object
org.instancio.util.NumberUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 & Comparable<T>>
TgetMaxValue
(Class<?> klass) static <T extends Number & Comparable<T>>
TgetMinValue
(Class<?> klass) getToLongConverter
(Class<?> klass)
-
Method Details
-
getMinValue
-
getMaxValue
-
getToLongConverter
-
calculateNewMin
public static <T extends Number & Comparable<T>> T calculateNewMin(@Nullable T curMin, T newMax, int percentage) Calculate a new minimum given the new maximum.If the new maximum is less than the current minimum, returns a new minimum value that is less 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 minimum is greater than the new maximum
-
calculateNewMax
public static <T extends Number & Comparable<T>> T calculateNewMax(@Nullable T curMax, T newMin, int percentage) Calculate a new maximum given the new minimum.If the new minimum is greater than 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 maximum is less than the new minimum
-