From e4af5b33b3cff966383797c07c606f68f5cebc76 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Tue, 4 Apr 2023 14:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E7=94=A8=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=20commons-collections4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ------ .../xyz/zhouxy/plusone/validator/CollectionValidator.java | 6 ++---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 9301502..12d02a5 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ 1.8 1.8 3.12.0 - 4.4 @@ -30,11 +29,6 @@ commons-lang3 ${commons-lang3.version} - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - org.junit.jupiter junit-jupiter-api diff --git a/src/main/java/xyz/zhouxy/plusone/validator/CollectionValidator.java b/src/main/java/xyz/zhouxy/plusone/validator/CollectionValidator.java index 4526988..cb434a1 100644 --- a/src/main/java/xyz/zhouxy/plusone/validator/CollectionValidator.java +++ b/src/main/java/xyz/zhouxy/plusone/validator/CollectionValidator.java @@ -4,8 +4,6 @@ import java.util.Collection; import java.util.function.Function; import java.util.function.Supplier; -import org.apache.commons.collections4.CollectionUtils; - public class CollectionValidator extends PropertyValidator, CollectionValidator> { CollectionValidator(Function> getter) { @@ -24,7 +22,7 @@ public class CollectionValidator extends PropertyValidator CollectionValidator notEmpty( Function, E> exceptionCreator) { - withRule(CollectionUtils::isNotEmpty, exceptionCreator); + withRule(value -> value != null && !value.isEmpty(), exceptionCreator); return this; } @@ -40,7 +38,7 @@ public class CollectionValidator extends PropertyValidator CollectionValidator isEmpty( Function, E> exceptionCreator) { - withRule(CollectionUtils::isEmpty, exceptionCreator); + withRule(value -> value == null || value.isEmpty(), exceptionCreator); return this; }