From 32ad8ad824683844c6dc65aca5b96a116038a954 Mon Sep 17 00:00:00 2001 From: VampireAchao Date: Tue, 8 Feb 2022 22:26:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=9C=A8ValidateException=E6=96=B0?= =?UTF-8?q?=E5=A2=9EmatchThrow=E5=92=8CnonMatchThrow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/exceptions/ValidateException.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java b/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java index 98423d60f..04f33fc0e 100644 --- a/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java +++ b/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java @@ -44,4 +44,29 @@ public class ValidateException extends StatefulException { public ValidateException(int status, String msg, Throwable throwable) { super(status, msg, throwable); } + + /** + * 满足条件就抛出异常 + * + * @param condition 条件 + * @param msg 异常消息 + */ + public static void matchThrow(boolean condition, String msg) { + if (condition) { + throw new ValidateException(msg); + } + } + + /** + * 不满足条件就抛出异常 + * + * @param condition 条件 + * @param msg 异常消息 + */ + public static void nonMatchThrow(boolean condition, String msg) { + if (false == condition) { + throw new ValidateException(msg); + } + } + } From 88a7fc7dc0ad6da876d1372b801eecd283559d28 Mon Sep 17 00:00:00 2001 From: VampireAchao Date: Fri, 11 Feb 2022 19:15:09 +0800 Subject: [PATCH 2/3] bug fix --- .../src/main/java/cn/hutool/core/stream/CollectorUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/stream/CollectorUtil.java b/hutool-core/src/main/java/cn/hutool/core/stream/CollectorUtil.java index 8e4001df4..e41e9b84f 100644 --- a/hutool-core/src/main/java/cn/hutool/core/stream/CollectorUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/stream/CollectorUtil.java @@ -114,7 +114,8 @@ public class CollectorUtil { if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { return new SimpleCollector<>(mangledFactory, accumulator, merger, CH_ID); } else { - UnaryOperator downstreamFinisher = (UnaryOperator) downstream.finisher(); + @SuppressWarnings("unchecked") + Function downstreamFinisher = (Function) downstream.finisher(); Function, M> finisher = intermediate -> { intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); @SuppressWarnings("unchecked") From 046bfead03275b68562f0d80fd74295b7dfd2b70 Mon Sep 17 00:00:00 2001 From: VampireAchao Date: Fri, 11 Feb 2022 19:20:57 +0800 Subject: [PATCH 3/3] bug fix --- .../core/exceptions/ValidateException.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java b/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java index 04f33fc0e..98423d60f 100644 --- a/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java +++ b/hutool-core/src/main/java/cn/hutool/core/exceptions/ValidateException.java @@ -44,29 +44,4 @@ public class ValidateException extends StatefulException { public ValidateException(int status, String msg, Throwable throwable) { super(status, msg, throwable); } - - /** - * 满足条件就抛出异常 - * - * @param condition 条件 - * @param msg 异常消息 - */ - public static void matchThrow(boolean condition, String msg) { - if (condition) { - throw new ValidateException(msg); - } - } - - /** - * 不满足条件就抛出异常 - * - * @param condition 条件 - * @param msg 异常消息 - */ - public static void nonMatchThrow(boolean condition, String msg) { - if (false == condition) { - throw new ValidateException(msg); - } - } - }