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
    private static <T> T[]
    clone(T... array)
    Clones the given array or returns null on null input.
    (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

    • clone

      private static <T> T[] clone(T... array)
      Clones the given array or returns null on null input.
      Type Parameters:
      T - The array type.
      Parameters:
      array - The array to clone.
      Returns:
      The cloned array or null.
    • 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 Transformer<? super I, ? extends O> to Transformer<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