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

java.lang.Object
  extended by org.apache.commons.collections.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:
Commons Collections 3.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:24 $
Author:
Matt Hall, John Watkinson, Stephen Colebourne
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>
getInstance(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 getInstance 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 getInstance if you want that.

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

getInstance

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

Parameters:
classToInstantiate - the class to instantiate, not null
paramTypes - the constructor parameter types
args - the constructor arguments
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 © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.