mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定范围内的随机数
|
||||
*
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user