org.apache.commons.collections4.functors

## Class ClosureTransformer<T>

- java.lang.Object
- - org.apache.commons.collections4.functors.ClosureTransformer<T>

- All Implemented Interfaces:
    Serializable, Transformer<T,T>

      public class ClosureTransformer<T>
      extends Object
      implements Transformer<T,T>, Serializable

  Transformer implementation that calls a Closure using the input object and then returns the input.
  Since:
    3.0
  Version:
    $Id: ClosureTransformer.java 1477798 2013-04-30 19:49:02Z tn $
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClosureTransformer(Closure<? super T> closure)` Constructor that performs no validation.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> Transformer<T,T>` | `closureTransformer(Closure<? super T> closure)` Factory method that performs validation.
    `Closure<? super T>` | `getClosure()` Gets the closure.
    `T` | `transform(T input)` Transforms the input to result by executing a closure.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClosureTransformer

          public ClosureTransformer(Closure<? super T> closure)

      Constructor that performs no validation. Use `closureTransformer` if you want that.
      Parameters:
        `closure` - the closure to call, not null

  - ### Method Detail

    - #### closureTransformer

          public static <T> Transformer<T,T> closureTransformer(Closure<? super T> closure)

      Factory method that performs validation.
      Type Parameters:
        `T` - the type of the object to transform
      Parameters:
        `closure` - the closure to call, not null
      Returns:
        the `closure` transformer
      Throws:
        `IllegalArgumentException` - if the closure is null

    - #### transform

          public T transform(T input)

      Transforms the input to result by executing a closure.
      Specified by:
        `transform` in interface `Transformer<T,T>`
      Parameters:
        `input` - the input object to transform
      Returns:
        the transformed result

    - #### getClosure

          public Closure<? super T> getClosure()

      Gets the closure.
      Returns:
        the closure
      Since:
        3.1

Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.