Class FunctorUtils

java.lang.Object
org.apache.commons.collections4.functors.FunctorUtils

final class FunctorUtils extends Object
Internal utilities for functors.
Since:
3.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Restricted constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static <R extends Predicate<T>, P extends Predicate<? super T>, T>
    R
    coerce(P predicate)
    A very simple method that coerces Predicateinvalid input: '<'? super T> to Predicate.
    (package private) static <T extends Consumer<?>>
    T[]
    copy(T... consumers)
    Clones the consumers to ensure that the internal references can't be updated.
    (package private) static <T> Predicate<? super T>[]
    validate(Collection<? extends Predicate<? super T>> predicates)
    Validate the predicates to ensure that all is well.
    (package private) static void
    validate(Consumer<?>... consumers)
    Validates the consumers to ensure that all is well.
    (package private) static void
    validate(Function<?,?>... functions)
    Validate method
    (package private) static void
    validate(Predicate<?>... predicates)
    Validate the predicates to ensure that all is well.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FunctorUtils

      private FunctorUtils()
      Restricted constructor.
  • Method Details

    • coerce

      static <R extends Predicate<T>, P extends Predicate<? super T>, T> R coerce(P predicate)
      A very simple method that coerces Predicateinvalid input: '<'? super T> to Predicate. Due to the
      invalid reference
      Predicate#test(T)
      method, Predicateinvalid input: '<'? super T> is able to be coerced to Predicate without casting issues.

      This method exists simply as centralized documentation and atomic unchecked warning suppression.

      Type Parameters:
      T - the type of object the returned predicate should "accept"
      Parameters:
      predicate - the predicate to coerce.
      Returns:
      the coerced predicate.
    • coerce

      static <R extends Function<I, O>, P extends Function<? super I, ? extends O>, I, O> R coerce(P transformer)
      A very simple method that coerces Transformerinvalid input: '<'? super I, ? extends O> to Transformerinvalid input: '<'I, O>.

      This method exists simply as centralized documentation and atomic unchecked warning suppression.

      Type Parameters:
      I - the type of object the returned transformer should "accept"
      O - the type of object the returned transformer should "produce"
      Parameters:
      transformer - the transformer to coerce.
      Returns:
      the coerced transformer.
    • copy

      static <T extends Consumer<?>> T[] copy(T... consumers)
      Clones the consumers to ensure that the internal references can't be updated.
      Parameters:
      consumers - the consumers to copy.
      Returns:
      the cloned consumers.
    • copy

      static <T extends Predicate<?>> T[] copy(T... predicates)
      Clone the predicates to ensure that the internal reference can't be messed with. Due to the
      invalid reference
      Predicate#test(T)
      method, Predicateinvalid input: '<'? super T> is able to be coerced to Predicate without casting issues.
      Parameters:
      predicates - the predicates to copy
      Returns:
      the cloned predicates
    • copy

      static <T extends Function<?, ?>> T[] copy(T... transformers)
      Copy method.
      Parameters:
      transformers - the transformers to copy
      Returns:
      a clone of the transformers
    • validate

      static <T> Predicate<? super T>[] validate(Collection<? extends Predicate<? super T>> predicates)
      Validate the predicates to ensure that all is well.
      Parameters:
      predicates - the predicates to validate
      Returns:
      predicate array
    • validate

      static void validate(Consumer<?>... consumers)
      Validates the consumers to ensure that all is well.
      Parameters:
      consumers - the consumers to validate.
    • validate

      static void validate(Function<?,?>... functions)
      Validate method
      Parameters:
      functions - the transformers to validate
    • validate

      static void validate(Predicate<?>... predicates)
      Validate the predicates to ensure that all is well.
      Parameters:
      predicates - the predicates to validate