Package org.apache.commons.collections4.functors

# Class TransformerClosure<T>

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

Type Parameters:
  `T` - The type of the input to the operation.

All Implemented Interfaces:
  `Serializable`, `Consumer<T>`, `Closure<T>`

public class TransformerClosure<T> extends Object implements Closure<T>, Serializable
Closure implementation that calls a Transformer using the input object and ignore the result.

Since:
  3.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TransformerClosure(Transformer<? super T,?> transformer)`
  Constructor that performs no validation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `execute(T input)`
  Executes the closure by calling the decorated transformer.
  `Transformer<? super T,?>`
  `getTransformer()`
  Gets the transformer.
  `static <E> Closure<E>`
  `transformerClosure(Transformer<? super E,?> transformer)`
  Factory method that performs validation.

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

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

  ### Methods inherited from interface org.apache.commons.collections4.Closure

  `accept`

  ### Methods inherited from interface java.util.function.Consumer

  `andThen`

- ## Constructor Details

  - ### TransformerClosure

    public TransformerClosure(Transformer<? super T,?> transformer)
    Constructor that performs no validation. Use `transformerClosure` if you want that.
    Parameters:
      `transformer` - The transformer to call, not null

- ## Method Details

  - ### transformerClosure

    public static <E> Closure<E> transformerClosure(Transformer<? super E,?> transformer)
    Factory method that performs validation.

    A null transformer will return the `NOPClosure`.

    Type Parameters:
      `E` - The type that the closure acts on
    Parameters:
      `transformer` - The transformer to call, null means nop
    Returns:
      The `transformer` closure

  - ### execute

    public void execute(T input)
    Executes the closure by calling the decorated transformer.
    Specified by:
      `execute` in interface `Closure<T>`
    Parameters:
      `input` - The input object

  - ### getTransformer

    public Transformer<? super T,?> getTransformer()
    Gets the transformer.
    Returns:
      The transformer
    Since:
      3.1