Class FunctorUtils


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

      Constructors 
      Modifier Constructor Description
      private FunctorUtils()
      Restricted constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <T> Closure<T> coerce​(Closure<? super T> closure)
      A very simple method that coerces Closure to Closure.
      (package private) static <T> Predicate<T> coerce​(Predicate<? super T> predicate)
      A very simple method that coerces Predicate to Predicate.
      (package private) static <I,​O>
      Transformer<I,​O>
      coerce​(Transformer<? super I,​? extends O> transformer)
      A very simple method that coerces Transformer to Transformer.
      (package private) static <E> Closure<E>[] copy​(Closure<? super E>... closures)
      Clone the closures to ensure that the internal reference can't be messed with.
      (package private) static <T> Predicate<T>[] copy​(Predicate<? super T>... predicates)
      Clone the predicates to ensure that the internal reference can't be messed with.
      (package private) static <I,​O>
      Transformer<I,​O>[]
      copy​(Transformer<? super I,​? extends O>... transformers)
      Copy method
      (package private) static <T> Predicate<? super T>[] validate​(java.util.Collection<? extends Predicate<? super T>> predicates)
      Validate the predicates to ensure that all is well.
      (package private) static void validate​(Closure<?>... closures)
      Validate the closures to ensure that all is well.
      (package private) static void validate​(Predicate<?>... predicates)
      Validate the predicates to ensure that all is well.
      (package private) static void validate​(Transformer<?,​?>... transformers)
      Validate method
      • Methods inherited from class java.lang.Object

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

      • FunctorUtils

        private FunctorUtils()
        Restricted constructor.
    • Method Detail

      • copy

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

        static <T> Predicate<T> coerce​(Predicate<? super T> predicate)
        A very simple method that coerces Predicate to Predicate. Due to the Predicate#evaluate(T) method, Predicate is able to be coerced to Predicate without casting issues.

        This method exists simply as centralised 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.
      • validate

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

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

        static <E> Closure<E>[] copy​(Closure<? super E>... closures)
        Clone the closures to ensure that the internal reference can't be messed with.
        Parameters:
        closures - the closures to copy
        Returns:
        the cloned closures
      • validate

        static void validate​(Closure<?>... closures)
        Validate the closures to ensure that all is well.
        Parameters:
        closures - the closures to validate
      • coerce

        static <T> Closure<T> coerce​(Closure<? super T> closure)
        A very simple method that coerces Closure to Closure.

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

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

        static <I,​O> Transformer<I,​O>[] copy​(Transformer<? super I,​? extends O>... transformers)
        Copy method
        Parameters:
        transformers - the transformers to copy
        Returns:
        a clone of the transformers
      • validate

        static void validate​(Transformer<?,​?>... transformers)
        Validate method
        Parameters:
        transformers - the transformers to validate
      • coerce

        static <I,​O> Transformer<I,​O> coerce​(Transformer<? super I,​? extends O> transformer)
        A very simple method that coerces Transformer to Transformer.

        This method exists simply as centralised 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.