Class Predicates

java.lang.Object
org.n52.janmayen.function.Predicates

public final class Predicates extends Object
Utility functions for Predicate.
  • Method Details

    • not

      public static <T> Predicate<T> not(Predicate<T> predicate)
      Negates the predicate.
      Type Parameters:
      T - the type of the input to the predicate
      Parameters:
      predicate - the predicate to negate
      Returns:
      the negated predicate
    • of

      public static <T> Predicate<T> of(Predicate<T> predicate)
      Creates a predicate.
      Type Parameters:
      T - the type of the input to the predicate
      Parameters:
      predicate - the predicate
      Returns:
      the predicate
    • alwaysFalse

      public static <T> Predicate<T> alwaysFalse()
      Creates a predicate that is always false.
      Type Parameters:
      T - the type of the input to the predicate
      Returns:
      the predicate
    • alwaysTrue

      public static <T> Predicate<T> alwaysTrue()
      Creates a predicate that is always true.
      Type Parameters:
      T - the type of the input to the predicate
      Returns:
      the predicate
    • constant

      public static <T> Predicate<T> constant(boolean value)
      Creates a predicate that returns a constant value.
      Type Parameters:
      T - the type of the input to the predicate
      Parameters:
      value - the constant value
      Returns:
      the predicate
    • instanceOf

      public static <T, U extends T> Predicate<T> instanceOf(@Nonnull Class<? extends U> clazz)
      Creates a Predicate that checks if it's input is an instance of clazz.
      Type Parameters:
      T - The input type.
      U - The type of which the input has to be an instance of.
      Parameters:
      clazz - The class of which the input has to be an instance of.
      Returns:
      The predicate.
    • curryFirst

      public static <T, U> Predicate<U> curryFirst(@Nonnull BiPredicate<T,U> predicate, T t)
      Curries the first parameter of the BiPredicate and creates a Predicate.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      Parameters:
      predicate - the predicate
      t - the curried parameter
      Returns:
      the curried predicate
    • currySecond

      public static <T, U> Predicate<T> currySecond(@Nonnull BiPredicate<T,U> predicate, U u)
      Curries the second parameter of the BiPredicate and creates a Predicate.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      Parameters:
      predicate - the predicate
      u - the curried parameter
      Returns:
      the curried predicate