From 7f80a411dba210808fc613ab6ada1b51b10224ca Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Thu, 14 Mar 2024 23:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B1=BB=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E4=B8=8E=20guava=20=E7=9A=84=20Predicates=20=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/{Predicates.java => PredicateTools.java} | 8 ++++---- .../zhouxy/plusone/commons/function/FunctionTests.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/xyz/zhouxy/plusone/commons/function/{Predicates.java => PredicateTools.java} (87%) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java b/src/main/java/xyz/zhouxy/plusone/commons/function/PredicateTools.java similarity index 87% rename from src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java rename to src/main/java/xyz/zhouxy/plusone/commons/function/PredicateTools.java index 5cb83a6..f28c770 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/function/PredicateTools.java @@ -29,7 +29,7 @@ import java.util.function.Predicate; * @since 0.1.0 * @see Predicate */ -public class Predicates { +public class PredicateTools { /** * 将 lambda 表达式或者方法引用指明为对应类型的 {@link Predicate} 对象。 @@ -38,7 +38,7 @@ public class Predicates { * 等方法,连接其它 {@code Predicate} 对象。 * *
-     * Predicate<String> predicate = Predicates.<String>of(Objects::nonNull)
+     * Predicate<String> predicate = PredicateTools.<String>from(Objects::nonNull)
      *         .and(StringUtils::isNotEmpty);
      * 
* @@ -46,11 +46,11 @@ public class Predicates { * @param predicate Lambda 表达式 * @return 传入的表达式自动成为 {@link Predicate} 实例 */ - public static Predicate of(Predicate predicate) { + public static Predicate from(Predicate predicate) { return predicate; } - private Predicates() { + private PredicateTools() { throw new IllegalStateException("Utility class"); } } diff --git a/src/test/java/xyz/zhouxy/plusone/commons/function/FunctionTests.java b/src/test/java/xyz/zhouxy/plusone/commons/function/FunctionTests.java index 2f5eade..e021238 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/function/FunctionTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/function/FunctionTests.java @@ -13,7 +13,7 @@ class FunctionTests { @Test void test() { String str = ""; - Predicate predicate = Predicates.of(Objects::nonNull) + Predicate predicate = PredicateTools.from(Objects::nonNull) .and(StringUtils::isNotBlank); assertFalse(predicate.test(str), "校验应是不通过"); }