Class Closures


  • public class Closures
    extends java.lang.Object
    Utilities related to creating Closures from Java.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> groovy.lang.Closure<T> from​(java.lang.Object owner, BiFunction<java.lang.Object,​java.lang.Object,​T> lambda)
      Create Closure from provided java lambda.
      static <T> groovy.lang.Closure<T> from​(java.lang.Object owner, Factory<T> lambda)
      Create Closure from provided java lambda.
      static <T> groovy.lang.Closure<T> from​(java.lang.Object owner, UnaryFunction<java.lang.Object,​T> lambda)
      Create Closure from provided java lambda.
      static <T> groovy.lang.Closure<T> fromArray​(java.lang.Object owner, UnaryFunction<java.lang.Object[],​T> lambda)
      Create Closure from provided java lambda.
      • Methods inherited from class java.lang.Object

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

      • from

        public static <T> groovy.lang.Closure<T> from​(java.lang.Object owner,
                                                      Factory<T> lambda)
        Create Closure from provided java lambda.
        Type Parameters:
        T - type parameter
        Parameters:
        owner - owner of the resulting Closure
        lambda - lambda supplier of resulting objects
        Returns:
        the closure
      • from

        public static <T> groovy.lang.Closure<T> from​(java.lang.Object owner,
                                                      UnaryFunction<java.lang.Object,​T> lambda)
        Create Closure from provided java lambda.
        Type Parameters:
        T - type parameter
        Parameters:
        owner - owner of the resulting Closure
        lambda - lambda function from Object to output type
        Returns:
        the closure
      • from

        public static <T> groovy.lang.Closure<T> from​(java.lang.Object owner,
                                                      BiFunction<java.lang.Object,​java.lang.Object,​T> lambda)
        Create Closure from provided java lambda.
        Type Parameters:
        T - type parameter
        Parameters:
        owner - owner of the resulting Closure
        lambda - lambda function of two arguments to output type
        Returns:
        the closure
      • fromArray

        public static <T> groovy.lang.Closure<T> fromArray​(java.lang.Object owner,
                                                           UnaryFunction<java.lang.Object[],​T> lambda)
        Create Closure from provided java lambda.
        Type Parameters:
        T - type parameter
        Parameters:
        owner - owner of the resulting Closure
        lambda - lambda function from Object[] to output type
        Returns:
        the closure