mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add isIn
This commit is contained in:
parent
3c7513a2bb
commit
9a6acc8329
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.8.5.M1 (2022-06-27)
|
# 5.8.5.M1 (2022-06-30)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
|
* 【core 】 NumberUtil新增isIn方法(pr#669@Gitee)
|
||||||
|
*
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1238,7 +1238,7 @@ public class NumberUtil {
|
|||||||
* @return 是否为整数
|
* @return 是否为整数
|
||||||
*/
|
*/
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
if(StrUtil.isBlank(s)) {
|
if (StrUtil.isBlank(s)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -1258,7 +1258,7 @@ public class NumberUtil {
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public static boolean isLong(String s) {
|
public static boolean isLong(String s) {
|
||||||
if(StrUtil.isBlank(s)) {
|
if (StrUtil.isBlank(s)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -1276,7 +1276,7 @@ public class NumberUtil {
|
|||||||
* @return 是否为{@link Double}类型
|
* @return 是否为{@link Double}类型
|
||||||
*/
|
*/
|
||||||
public static boolean isDouble(String s) {
|
public static boolean isDouble(String s) {
|
||||||
if(StrUtil.isBlank(s)) {
|
if (StrUtil.isBlank(s)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -1816,19 +1816,17 @@ public class NumberUtil {
|
|||||||
/**
|
/**
|
||||||
* 检查值是否在指定范围内
|
* 检查值是否在指定范围内
|
||||||
*
|
*
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @param min 最小值(包含)
|
* @param minInclude 最小值(包含)
|
||||||
* @param max 最大值(包含)
|
* @param maxInclude 最大值(包含)
|
||||||
* @return 经过检查后的值
|
* @return 经过检查后的值
|
||||||
**/
|
* @since 5.8.5
|
||||||
public static boolean isIn(final BigDecimal value, final BigDecimal min,final BigDecimal max){
|
*/
|
||||||
|
public static boolean isIn(final BigDecimal value, final BigDecimal minInclude, final BigDecimal maxInclude) {
|
||||||
Assert.notNull(value);
|
Assert.notNull(value);
|
||||||
Assert.notNull(min);
|
Assert.notNull(minInclude);
|
||||||
Assert.notNull(max);
|
Assert.notNull(maxInclude);
|
||||||
if(isGreaterOrEqual(value,min) && isLessOrEqual(value,max)){
|
return isGreaterOrEqual(value, minInclude) && isLessOrEqual(value, maxInclude);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2550,7 +2548,7 @@ public class NumberUtil {
|
|||||||
* @since 4.1.15
|
* @since 4.1.15
|
||||||
*/
|
*/
|
||||||
public static Number parseNumber(String numberStr) throws NumberFormatException {
|
public static Number parseNumber(String numberStr) throws NumberFormatException {
|
||||||
if(StrUtil.startWithIgnoreCase(numberStr, "0x")){
|
if (StrUtil.startWithIgnoreCase(numberStr, "0x")) {
|
||||||
// 0x04表示16进制数
|
// 0x04表示16进制数
|
||||||
return Long.parseLong(numberStr.substring(2), 16);
|
return Long.parseLong(numberStr.substring(2), 16);
|
||||||
}
|
}
|
||||||
@ -2688,7 +2686,7 @@ public class NumberUtil {
|
|||||||
* @since 4.6.7
|
* @since 4.6.7
|
||||||
*/
|
*/
|
||||||
public static boolean isValidNumber(Number number) {
|
public static boolean isValidNumber(Number number) {
|
||||||
if(null == number){
|
if (null == number) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (number instanceof Double) {
|
if (number instanceof Double) {
|
||||||
|
Loading…
Reference in New Issue
Block a user