public class NumberUtil
extends org.apache.commons.lang3.math.NumberUtils
NumberUtils 进行拓展| 限定符 | 构造器和说明 |
|---|---|
protected |
NumberUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T extends Number> |
add(T a,
T b,
int decimal)
a+b and Keep 'decimal' decimals
|
static BigDecimal |
decimalsXLength(int length,
BigDecimal old)
保留指定小数长度的数据
|
static <T extends Number> |
divide(T a,
T b,
int decimal)
a/b and Keep 'decimal' decimals
|
static <N> boolean |
eq(N input,
N values)
判断values等于input的值
|
static <N> boolean |
in(N input,
N... values)
判断values是否包含input的值
|
static <T extends Number> |
isNumbers(Class<T> type,
String... str)
判断字符串是否是数字(指定类型)
|
static boolean |
isNumbers(String... str)
判断字符串是否是数字(无法具体判断是整型还是浮点型)
|
static <T extends Number> |
multiply(T a,
T b,
int decimal)
a*b and Keep 'decimal' decimals
|
static <N> boolean |
ne(N input,
N values)
判断values不等于input的值
|
static <N> boolean |
notIn(N input,
N... values)
判断values是否包含input的值
|
static <T extends Number> |
remainder(T a,
T b,
int decimal)
a%b and Keep 'decimal' decimals
|
static <T extends Number> |
subtract(T a,
T b,
int decimal)
like a-b and Keep 'decimal' decimals
|
static <N> N |
validate(N input,
N compare,
N defaultValue)
数值校验 如果为true返回默认值
|
compare, compare, compare, compare, createBigDecimal, createBigInteger, createDouble, createFloat, createInteger, createLong, createNumber, isCreatable, isDigits, isNumber, isParsable, max, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, min, toByte, toByte, toDouble, toDouble, toFloat, toFloat, toInt, toInt, toLong, toLong, toShort, toShortpublic static boolean isNumbers(String... str)
str - public static <T extends Number> boolean isNumbers(Class<T> type, String... str)
str - public static BigDecimal decimalsXLength(int length, BigDecimal old)
public static <T extends Number> BigDecimal add(T a, T b, int decimal)
T - must extend Numberpublic static <T extends Number> BigDecimal subtract(T a, T b, int decimal)
T - must extend Numberpublic static <T extends Number> BigDecimal divide(T a, T b, int decimal)
T - must extend Numberpublic static <T extends Number> BigDecimal multiply(T a, T b, int decimal)
T - must extend Numberpublic static <T extends Number> BigDecimal remainder(T a, T b, int decimal)
T - must extend Numberpublic static <N> N validate(N input,
N compare,
N defaultValue)
input - 需要验证的值compare - 与验证值比较的值defaultValue - 如果input为空或者 input与compare验证结果为true 则返回默认值public static <N> boolean in(N input,
N... values)
public static <N> boolean notIn(N input,
N... values)
public static <N> boolean eq(N input,
N values)
public static <N> boolean ne(N input,
N values)
Copyright © 2020. All rights reserved.