暂时用不到 commons-collections4。
parent
3b040a442d
commit
e4af5b33b3
6
pom.xml
6
pom.xml
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue