add method

This commit is contained in:
Looly 2021-10-14 09:56:04 +08:00
parent d204d58057
commit b5036b4b0b
4 changed files with 29 additions and 12 deletions

View File

@ -8,6 +8,7 @@
### 🐣新特性
* 【db 】 Db.quietSetAutoCommit增加判空issue#I4D75B@Gitee
* 【core 】 增加RingIndexUtilpr#438@Gitee
* 【core 】 Assert增加checkBetween重载pr#436@Gitee
*
### 🐞Bug修复
* 【core 】 修复CollUtil.isEqualList两个null返回错误问题issue#1885@Github

View File

@ -840,12 +840,12 @@ public class Assert {
/**
* 检查值是否在指定范围内
*
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param errorSupplier 错误抛出异常附带的消息生产接口
* @throws X if value is out of bound
* @return 经过检查后的值
* @throws X if value is out of bound
* @since 5.7.15
*/
public static <X extends Throwable> int checkBetween(int value, int min, int max, Supplier<? extends X> errorSupplier) throws X {
@ -885,12 +885,12 @@ public class Assert {
/**
* 检查值是否在指定范围内
*
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param errorSupplier 错误抛出异常附带的消息生产接口
* @throws X if value is out of bound
* @return 经过检查后的值
* @throws X if value is out of bound
* @since 5.7.15
*/
public static <X extends Throwable> long checkBetween(long value, long min, long max, Supplier<? extends X> errorSupplier) throws X {
@ -930,12 +930,12 @@ public class Assert {
/**
* 检查值是否在指定范围内
*
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param value
* @param min 最小值包含
* @param max 最大值包含
* @param errorSupplier 错误抛出异常附带的消息生产接口
* @throws X if value is out of bound
* @return 经过检查后的值
* @throws X if value is out of bound
* @since 5.7.15
*/
public static <X extends Throwable> double checkBetween(double value, double min, double max, Supplier<? extends X> errorSupplier) throws X {

View File

@ -163,6 +163,16 @@ public class RandomUtil {
return 0 == randomInt(2);
}
/**
* 随机汉字'\u4E00'-'\u9FFF'
*
* @return 随机的汉字字符
* @since 5.7.15
*/
public static char randomChinese() {
return (char) randomInt('\u4E00', '\u9FFF');
}
/**
* 获得指定范围内的随机数
*

View File

@ -53,4 +53,10 @@ public class RandomUtilTest {
final byte[] c = RandomUtil.randomBytes(10);
Assert.assertNotNull(c);
}
@Test
public void randomChineseTest(){
char c = RandomUtil.randomChinese();
Assert.assertTrue(c > 0);
}
}