Package org.instancio.internal.util
Class NumberUtils
java.lang.Object
org.instancio.internal.util.NumberUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Number>
Function<BigDecimal,T> bigDecimalConverter(Class<?> klass) static <T extends Number & Comparable<T>>
TcalculateNewMax(T curMax, T newMin, int percentage) Calculate a new maximum given the new minimum.static intcalculateNewMaxSize(@Nullable Integer curMax, Integer newMin) static <T extends Number & Comparable<T>>
TcalculateNewMin(T curMin, T newMax, int percentage) Calculate a new minimum given the new maximum.static intcalculateNewMinSize(@Nullable Integer curMin, Integer newMax) static <T extends Number & Comparable<T>>
TgetMaxValue(Class<?> klass) static <T extends Number & Comparable<T>>
TgetMinValue(Class<?> klass) longConverter(Class<?> klass) static intsumDigits(int num)
-
Method Details
-
getMinValue
-
getMaxValue
-
longConverter
-
bigDecimalConverter
-
calculateNewMin
public static <T extends Number & Comparable<T>> T calculateNewMin(@Nullable T curMin, @NotNull 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, @NotNull 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
-
calculateNewMinSize
-
calculateNewMaxSize
-
sumDigits
public static int sumDigits(int num)
-