暂时用不到 commons-collections4。

pull/1/head
ZhouXY108 2023-04-04 14:58:41 +08:00
parent 3b040a442d
commit e4af5b33b3
2 changed files with 2 additions and 10 deletions

View File

@ -16,7 +16,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-collections4.version>4.4</commons-collections4.version>
</properties>
<dependencies>
@ -30,11 +29,6 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>

View File

@ -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<DTO, T> extends PropertyValidator<DTO, Collection<T>, CollectionValidator<DTO, T>> {
CollectionValidator(Function<DTO, Collection<T>> getter) {
@ -24,7 +22,7 @@ public class CollectionValidator<DTO, T> extends PropertyValidator<DTO, Collecti
public <E extends RuntimeException> CollectionValidator<DTO, T> notEmpty(
Function<Collection<T>, E> exceptionCreator) {
withRule(CollectionUtils::isNotEmpty, exceptionCreator);
withRule(value -> value != null && !value.isEmpty(), exceptionCreator);
return this;
}
@ -40,7 +38,7 @@ public class CollectionValidator<DTO, T> extends PropertyValidator<DTO, Collecti
public <E extends RuntimeException> CollectionValidator<DTO, T> isEmpty(
Function<Collection<T>, E> exceptionCreator) {
withRule(CollectionUtils::isEmpty, exceptionCreator);
withRule(value -> value == null || value.isEmpty(), exceptionCreator);
return this;
}