forked from plusone/plusone-commons
优化功能
This commit is contained in:
@@ -6,7 +6,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public class BigDecimals {
|
||||
@@ -17,21 +16,26 @@ public class BigDecimals {
|
||||
return (a == b) || (a != null && a.compareTo(b) == 0);
|
||||
}
|
||||
|
||||
@Beta
|
||||
public static boolean greaterThan(BigDecimal a, BigDecimal b) {
|
||||
public static boolean gt(BigDecimal a, BigDecimal b) {
|
||||
Preconditions.checkNotNull(a, "Parameter could not be null.");
|
||||
Preconditions.checkNotNull(b, "Parameter could not be null.");
|
||||
return (a != b) && (a.compareTo(b) > 0);
|
||||
}
|
||||
|
||||
@Beta
|
||||
public static boolean lessThan(BigDecimal a, BigDecimal b) {
|
||||
public static boolean ge(BigDecimal a, BigDecimal b) {
|
||||
return gt(a, b) || equals(a, b);
|
||||
}
|
||||
|
||||
public static boolean lt(BigDecimal a, BigDecimal b) {
|
||||
Preconditions.checkNotNull(a, "Parameter could not be null.");
|
||||
Preconditions.checkNotNull(b, "Parameter could not be null.");
|
||||
return (a != b) && (a.compareTo(b) < 0);
|
||||
}
|
||||
|
||||
@Beta
|
||||
public static boolean le(BigDecimal a, BigDecimal b) {
|
||||
return lt(a, b) || equals(a, b);
|
||||
}
|
||||
|
||||
public static BigDecimal of(final String val) {
|
||||
return (StringUtils.isBlank(val)) ? ZERO : new BigDecimal(val);
|
||||
}
|
||||
|
Reference in New Issue
Block a user