Interface ToBooleanFunction<T>

Type Parameters:
T - the input type
All Superinterfaces:
Predicate<T>, ToPrimitiveFunction<T>, TypedFunction<T>
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 ToBooleanFunction<T> extends ToPrimitiveFunction<T>, Predicate<T>
A boolean function.
  • Method Details

    • cast

      static <T> ToBooleanFunction<T> cast()
      Assumes the object value is directly castable to a boolean. Equivalent to x -> (boolean)x.
      Type Parameters:
      T - the value type
      Returns:
      the boolean function
    • ofTrue

      static <T> ToBooleanFunction<T> ofTrue()
      A function that always returns true.
      Type Parameters:
      T - the input type
      Returns:
      the true function
    • ofFalse

      static <T> ToBooleanFunction<T> ofFalse()
      A function that always returns false.
      Type Parameters:
      T - the input type
      Returns:
      the false function
    • map

      static <T, R> ToBooleanFunction<T> map(Function<? super T,? extends R> f, Predicate<? super R> g)
      Creates the function composition g ∘ f.

      Equivalent to x -> g.test(f.apply(x)).

      Type Parameters:
      T - the input type
      R - the intermediate type
      Parameters:
      f - the inner function
      g - the outer function
      Returns:
      the boolean function
    • or

      static <T> ToBooleanFunction<T> or(Collection<Predicate<? super T>> functions)
      Creates a function that returns true if any function in functions returns true. If functions is empty, returns ofFalse().
      Type Parameters:
      T - the input type
      Parameters:
      functions - the functions
      Returns:
      the or-function
    • and

      static <T> ToBooleanFunction<T> and(Collection<Predicate<? super T>> functions)
      Creates a function that returns true if all functions in functions returns true. If functions is empty, returns ofTrue().
      Type Parameters:
      T - the input type
      Parameters:
      functions - the functions
      Returns:
      the and-function
    • not

      static <T> ToBooleanFunction<T> not(Predicate<? super T> f)
      Creates a function that is the opposite of f. Equivalent to x -> !f.test(x).
      Type Parameters:
      T - the input type
      Parameters:
      f - the function
      Returns:
      the not-function
    • test

      boolean test(T value)
      Specified by:
      test in interface Predicate<T>
    • returnType

      default BooleanType returnType()
      Description copied from interface: TypedFunction
      This function's return type.
      Specified by:
      returnType in interface ToPrimitiveFunction<T>
      Specified by:
      returnType in interface TypedFunction<T>
      Returns:
      the type
    • walk

      default <R> R walk(ToPrimitiveFunction.Visitor<T,R> visitor)
      Specified by:
      walk in interface ToPrimitiveFunction<T>
    • negate

      @NotNull default @NotNull ToBooleanFunction<T> negate()
      Specified by:
      negate in interface Predicate<T>
    • and

      @NotNull default @NotNull ToBooleanFunction<T> and(@NotNull @NotNull Predicate<? super T> other)
      Specified by:
      and in interface Predicate<T>
    • or

      @NotNull default @NotNull ToBooleanFunction<T> or(@NotNull @NotNull Predicate<? super T> other)
      Specified by:
      or in interface Predicate<T>