简化代码。

pull/1/head
ZhouXY108 2023-04-04 00:03:46 +08:00
parent 17f7a1f4ac
commit 3c14fb0656
1 changed files with 2 additions and 12 deletions

View File

@ -162,12 +162,7 @@ public class StringValidator<DTO> extends PropertyValidator<DTO, String, StringV
public <E extends RuntimeException> StringValidator<DTO> notEmpty(
Function<String, E> exceptionCreator) {
withRule(value -> {
if (value == null) {
return false;
}
return !(value.isEmpty());
}, exceptionCreator);
withRule(value -> (value != null) && (!value.isEmpty()), exceptionCreator);
return this;
}
@ -183,12 +178,7 @@ public class StringValidator<DTO> extends PropertyValidator<DTO, String, StringV
public <E extends RuntimeException> StringValidator<DTO> isEmpty(
Function<String, E> exceptionCreator) {
withRule(value -> {
if (value == null) {
return true;
}
return value.isEmpty();
}, exceptionCreator);
withRule(value -> value == null || value.isEmpty(), exceptionCreator);
return this;
}