暂时用不到 commons-collections4。
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user