diff --git a/CHANGELOG.md b/CHANGELOG.md index 905612610..f854a8372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### 🐣新特性 * 【db 】 Db.quietSetAutoCommit增加判空(issue#I4D75B@Gitee) * 【core 】 增加RingIndexUtil(pr#438@Gitee) +* 【core 】 Assert增加checkBetween重载(pr#436@Gitee) * ### 🐞Bug修复 * 【core 】 修复CollUtil.isEqualList两个null返回错误问题(issue#1885@Github) diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java b/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java index e97735163..fd4751d6a 100644 --- a/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java +++ b/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java @@ -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 int checkBetween(int value, int min, int max, Supplier 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 long checkBetween(long value, long min, long max, Supplier 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 double checkBetween(double value, double min, double max, Supplier errorSupplier) throws X { diff --git a/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java index aae07f8be..8d77384e7 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java @@ -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'); + } + /** * 获得指定范围内的随机数 * diff --git a/hutool-core/src/test/java/cn/hutool/core/util/RandomUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/util/RandomUtilTest.java index 42ba46299..978fcd2ed 100644 --- a/hutool-core/src/test/java/cn/hutool/core/util/RandomUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/util/RandomUtilTest.java @@ -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); + } }