forked from plusone/plusone-commons
优化功能
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package xyz.zhouxy.plusone.commons.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Numbers
|
||||
*
|
||||
@@ -23,10 +25,6 @@ package xyz.zhouxy.plusone.commons.util;
|
||||
*/
|
||||
public class Numbers {
|
||||
|
||||
private Numbers() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
// sum
|
||||
|
||||
public static int sum(final short... numbers) {
|
||||
@@ -69,6 +67,14 @@ public class Numbers {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BigDecimal sum(final BigDecimal... numbers) {
|
||||
BigDecimal result = BigDecimals.of("0.00");
|
||||
for (BigDecimal number : numbers) {
|
||||
result = result.add(number);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// between
|
||||
|
||||
public static boolean between(short value, short min, short max) {
|
||||
@@ -90,4 +96,12 @@ public class Numbers {
|
||||
public static boolean between(double value, double min, double max) {
|
||||
return value >= min && value < max;
|
||||
}
|
||||
|
||||
public static boolean between(BigDecimal value, BigDecimal min, BigDecimal max) {
|
||||
return BigDecimals.ge(value, min) && BigDecimals.lt(value, max);
|
||||
}
|
||||
|
||||
private Numbers() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user