org.apache.commons.collections4.functors
Class InstantiateTransformer<T>

java.lang.Object
  extended by org.apache.commons.collections4.functors.InstantiateTransformer<T>
All Implemented Interfaces:
Serializable, Transformer<Class<? extends T>,T>

public class InstantiateTransformer<T>
extends Object
implements Transformer<Class<? extends T>,T>, Serializable

Transformer implementation that creates a new object instance by reflection.

Since:
3.0
Version:
$Id: InstantiateTransformer.java 1477839 2013-04-30 21:32:47Z tn $
See Also:
Serialized Form

Field Summary
static Transformer<Class<?>,?> NO_ARG_INSTANCE
          Singleton instance that uses the no arg constructor
 
Constructor Summary
InstantiateTransformer(Class<?>[] paramTypes, Object[] args)
          Constructor that performs no validation.
 
Method Summary
static
<T> Transformer<Class<? extends T>,T>
instantiateTransformer()
          Get a typed no-arg instance.
static
<T> Transformer<Class<? extends T>,T>
instantiateTransformer(Class<?>[] paramTypes, Object[] args)
          Transformer method that performs validation.
 T transform(Class<? extends T> input)
          Transforms the input Class object to a result by instantiation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ARG_INSTANCE

public static final Transformer<Class<?>,?> NO_ARG_INSTANCE
Singleton instance that uses the no arg constructor

Constructor Detail

InstantiateTransformer

public InstantiateTransformer(Class<?>[] paramTypes,
                              Object[] args)
Constructor that performs no validation. Use instantiateTransformer if you want that.

Note: from 4.0, the input parameters will be cloned

Parameters:
paramTypes - the constructor parameter types
args - the constructor arguments
Method Detail

instantiateTransformer

public static <T> Transformer<Class<? extends T>,T> instantiateTransformer()
Get a typed no-arg instance.

Type Parameters:
T - the type of the objects to be created
Returns:
Transformer, T>

instantiateTransformer

public static <T> Transformer<Class<? extends T>,T> instantiateTransformer(Class<?>[] paramTypes,
                                                                           Object[] args)
Transformer method that performs validation.

Type Parameters:
T - the type of the objects to be created
Parameters:
paramTypes - the constructor parameter types
args - the constructor arguments
Returns:
an instantiate transformer

transform

public T transform(Class<? extends T> input)
Transforms the input Class object to a result by instantiation.

Specified by:
transform in interface Transformer<Class<? extends T>,T>
Parameters:
input - the input object to transform
Returns:
the transformed result


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