Class PredicateUtil

java.lang.Object
de.tomatengames.util.PredicateUtil

public class PredicateUtil extends Object
Provides methods to combine Predicate objects.
Since:
1.2
  • Method Details

    • not

      public static <T> @NotNull Predicate<T> not(@NotNull Predicate<T> pred)
      Returns the logical negation of the specified Predicate.
      Type Parameters:
      T - The type of the input parameter.
      Parameters:
      pred - The predicate that should be negated. Must not be null.
      Returns:
      The logical negation of the specified predicate.
      Throws:
      NullPointerException - If the specified predicate is null.
    • and

      public static <T> @NotNull Predicate<T> and(@NotNull Predicate<? super T> pred1, @NotNull Predicate<? super T> pred2)
      Returns a Predicate that represents (pred1.test(t) && pred2.test(t)).
      Type Parameters:
      T - The type of the input parameter.
      Parameters:
      pred1 - The first predicate. Must not be null.
      pred2 - The second predicate. Must not be null.
      Returns:
      A predicate that combines both predicates with a logical AND.
      Throws:
      NullPointerException - If a specified predicate is null.
    • or

      public static <T> @NotNull Predicate<T> or(@NotNull Predicate<? super T> pred1, @NotNull Predicate<? super T> pred2)
      Returns a Predicate that represents (pred1.test(t) || pred2.test(t)).
      Type Parameters:
      T - The type of the input parameter.
      Parameters:
      pred1 - The first predicate. Must not be null.
      pred2 - The second predicate. Must not be null.
      Returns:
      A predicate that combines both predicates with a logical OR.
      Throws:
      NullPointerException - If a specified predicate is null.