From 3c14fb06561e3f6ce0ae0a39b62d69d36de58145 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Tue, 4 Apr 2023 00:03:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhouxy/plusone/validator/StringValidator.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) 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; }