Interface SerializablePredicate<T>

Type Parameters:
T - the input type | 输入类型
All Superinterfaces:
Predicate<T>, Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SerializablePredicate<T> extends Predicate<T>, Serializable
Serializable Predicate Interface 可序列化Predicate接口

A Predicate that is also Serializable, enabling lambda metadata extraction.

一个同时也是Serializable的Predicate,可以提取lambda元数据。

Features | 主要功能:

  • Serializable Predicate for lambda metadata extraction - 可序列化Predicate用于lambda元数据提取
  • Composable with and, or, negate - 可通过and、or、negate组合
  • Factory methods: alwaysTrue, alwaysFalse, isNull, nonNull, isEqual - 工厂方法

Usage Examples | 使用示例:

SerializablePredicate<String> notEmpty = s -> !s.isEmpty();
boolean result = notEmpty.test("hello"); // true

Security | 安全性:

  • Thread-safe: Depends on implementation - 线程安全: 取决于实现
  • Null-safe: Depends on implementation - 空值安全: 取决于实现
Since:
JDK 25, opencode-base-reflect V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      static <T> SerializablePredicate<T> of(SerializablePredicate<T> predicate)
      Creates a SerializablePredicate 创建SerializablePredicate
      Type Parameters:
      T - the input type | 输入类型
      Parameters:
      predicate - the predicate | 谓词
      Returns:
      the serializable predicate | 可序列化谓词
    • alwaysTrue

      static <T> SerializablePredicate<T> alwaysTrue()
      Creates a predicate that always returns true 创建总是返回true的谓词
      Type Parameters:
      T - the input type | 输入类型
      Returns:
      the always-true predicate | 总是true的谓词
    • alwaysFalse

      static <T> SerializablePredicate<T> alwaysFalse()
      Creates a predicate that always returns false 创建总是返回false的谓词
      Type Parameters:
      T - the input type | 输入类型
      Returns:
      the always-false predicate | 总是false的谓词
    • isNull

      static <T> SerializablePredicate<T> isNull()
      Creates a predicate that checks for null 创建检查null的谓词
      Type Parameters:
      T - the input type | 输入类型
      Returns:
      the null-checking predicate | 检查null的谓词
    • nonNull

      static <T> SerializablePredicate<T> nonNull()
      Creates a predicate that checks for non-null 创建检查非null的谓词
      Type Parameters:
      T - the input type | 输入类型
      Returns:
      the non-null-checking predicate | 检查非null的谓词
    • isEqual

      static <T> SerializablePredicate<T> isEqual(Object targetRef)
      Creates a predicate that checks equality with a value 创建检查与值相等的谓词
      Type Parameters:
      T - the input type | 输入类型
      Parameters:
      targetRef - the target reference | 目标引用
      Returns:
      the equality predicate | 相等谓词
    • and

      default SerializablePredicate<T> and(SerializablePredicate<? super T> other)
      Returns a composed predicate (AND) 返回组合谓词(AND)
      Parameters:
      other - the other predicate | 另一个谓词
      Returns:
      the composed predicate | 组合后的谓词
    • negate

      default SerializablePredicate<T> negate()
      Returns a negated predicate 返回否定的谓词
      Specified by:
      negate in interface Predicate<T>
      Returns:
      the negated predicate | 否定的谓词
    • or

      default SerializablePredicate<T> or(SerializablePredicate<? super T> other)
      Returns a composed predicate (OR) 返回组合谓词(OR)
      Parameters:
      other - the other predicate | 另一个谓词
      Returns:
      the composed predicate | 组合后的谓词