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

java.lang.Object
  extended by org.apache.commons.collections4.functors.InstantiateFactory<T>
All Implemented Interfaces:
Serializable, Factory<T>

public class InstantiateFactory<T>
extends Object
implements Factory<T>, Serializable

Factory implementation that creates a new object instance by reflection.

Since:
3.0
Version:
$Id: InstantiateFactory.java 1477798 2013-04-30 19:49:02Z tn $
See Also:
Serialized Form

Constructor Summary
InstantiateFactory(Class<T> classToInstantiate)
          Constructor that performs no validation.
InstantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args)
          Constructor that performs no validation.
 
Method Summary
 T create()
          Creates an object using the stored constructor.
static
<T> Factory<T>
instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args)
          Factory method that performs validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstantiateFactory

public InstantiateFactory(Class<T> classToInstantiate)
Constructor that performs no validation. Use instantiateFactory if you want that.

Parameters:
classToInstantiate - the class to instantiate

InstantiateFactory

public InstantiateFactory(Class<T> classToInstantiate,
                          Class<?>[] paramTypes,
                          Object[] args)
Constructor that performs no validation. Use instantiateFactory if you want that.

Parameters:
classToInstantiate - the class to instantiate
paramTypes - the constructor parameter types, cloned
args - the constructor arguments, cloned
Method Detail

instantiateFactory

public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate,
                                                Class<?>[] paramTypes,
                                                Object[] args)
Factory method that performs validation.

Type Parameters:
T - the type the factory creates
Parameters:
classToInstantiate - the class to instantiate, not null
paramTypes - the constructor parameter types, cloned
args - the constructor arguments, cloned
Returns:
a new instantiate factory

create

public T create()
Creates an object using the stored constructor.

Specified by:
create in interface Factory<T>
Returns:
the new object


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