diff --git a/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java b/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java index 7996810..8494fd9 100644 --- a/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java +++ b/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java @@ -162,12 +162,7 @@ public class StringValidator extends PropertyValidator StringValidator notEmpty( Function 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 extends PropertyValidator StringValidator isEmpty( Function exceptionCreator) { - withRule(value -> { - if (value == null) { - return true; - } - return value.isEmpty(); - }, exceptionCreator); + withRule(value -> value == null || value.isEmpty(), exceptionCreator); return this; }