# Class FactoryTransformer<T,R>

java.lang.Object
org.apache.commons.collections4.functors.FactoryTransformer<T,R>

Type Parameters:
  `T` - the type of the input to the function.
  `R` - the type of the result of the function.

All Implemented Interfaces:
  `Serializable`, `Function<T,R>`, `Transformer<T,R>`

public class FactoryTransformer<T,R> extends Object implements Transformer<T,R>, Serializable
Transformer implementation that calls a Factory and returns the result.

Since:
  3.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FactoryTransformer(Factory<? extends R> factory)`
  Constructor that performs no validation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <I, O> Transformer<I,O>`
  `factoryTransformer(Factory<? extends O> factory)`
  Factory method that performs validation.
  `Factory<? extends R>`
  `getFactory()`
  Gets the factory.
  `R`
  `transform(T input)`
  Transforms the input by ignoring the input and returning the result of calling the decorated factory.

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

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

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

  `andThen, compose`

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

  `apply`

- ## Constructor Details

  - ### FactoryTransformer

    public FactoryTransformer(Factory<? extends R> factory)
    Constructor that performs no validation. Use `factoryTransformer` if you want that.
    Parameters:
      `factory` - the factory to call, not null

- ## Method Details

  - ### factoryTransformer

    public static <I, O> Transformer<I,O> factoryTransformer(Factory<? extends O> factory)
    Factory method that performs validation.
    Type Parameters:
      `I` - the input type
      `O` - the output type
    Parameters:
      `factory` - the factory to call, not null
    Returns:
      the `factory` transformer
    Throws:
      `NullPointerException` - if the factory is null

  - ### getFactory

    public Factory<? extends R> getFactory()
    Gets the factory.
    Returns:
      the factory
    Since:
      3.1

  - ### transform

    public R transform(T input)
    Transforms the input by ignoring the input and returning the result of calling the decorated factory.
    Specified by:
      `transform` in interface `Transformer<T,R>`
    Parameters:
      `input` - the input object to transform
    Returns:
      the transformed result