Author: bayard Date: Tue Sep 15 05:55:08 2009 New Revision: 815049 URL: http://svn.apache.org/viewvc?rev=815049&view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.
Also see the following revisions: ------------------------------------------------------------------------ r570378 | skestle | 2007-08-28 04:03:40 -0700 (Tue, 28 Aug 2007) | 1 line Generified InstantiateFactory ------------------------------------------------------------------------ Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateFactory.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateFactory.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateFactory.java?rev=815049&r1=815048&r2=815049&view=diff ============================================================================== --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateFactory.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateFactory.java Tue Sep 15 05:55:08 2009 @@ -31,19 +31,19 @@ * * @author Stephen Colebourne */ -public class InstantiateFactory implements Factory, Serializable { +public class InstantiateFactory<T> implements Factory<T>, Serializable { /** The serial version */ private static final long serialVersionUID = -7732226881069447957L; /** The class to create */ - private final Class iClassToInstantiate; + private final Class<T> iClassToInstantiate; /** The constructor parameter types */ - private final Class[] iParamTypes; + private final Class<?>[] iParamTypes; /** The constructor arguments */ private final Object[] iArgs; /** The constructor */ - private transient Constructor iConstructor = null; + private transient Constructor<T> iConstructor = null; /** * Factory method that performs validation. @@ -53,7 +53,7 @@ * @param args the constructor arguments * @return a new instantiate factory */ - public static Factory getInstance(Class classToInstantiate, Class[] paramTypes, Object[] args) { + public static <T> Factory<T> getInstance(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) { if (classToInstantiate == null) { throw new IllegalArgumentException("Class to instantiate must not be null"); } @@ -64,12 +64,11 @@ } if (paramTypes == null || paramTypes.length == 0) { - return new InstantiateFactory(classToInstantiate); - } else { - paramTypes = (Class[]) paramTypes.clone(); - args = (Object[]) args.clone(); - return new InstantiateFactory(classToInstantiate, paramTypes, args); + return new InstantiateFactory<T>(classToInstantiate); } + paramTypes = paramTypes.clone(); + args = args.clone(); + return new InstantiateFactory<T>(classToInstantiate, paramTypes, args); } /** @@ -78,7 +77,7 @@ * * @param classToInstantiate the class to instantiate */ - public InstantiateFactory(Class classToInstantiate) { + public InstantiateFactory(Class<T> classToInstantiate) { super(); iClassToInstantiate = classToInstantiate; iParamTypes = null; @@ -94,7 +93,7 @@ * @param paramTypes the constructor parameter types, not cloned * @param args the constructor arguments, not cloned */ - public InstantiateFactory(Class classToInstantiate, Class[] paramTypes, Object[] args) { + public InstantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) { super(); iClassToInstantiate = classToInstantiate; iParamTypes = paramTypes; @@ -119,7 +118,7 @@ * * @return the new object */ - public Object create() { + public T create() { // needed for post-serialization if (iConstructor == null) { findConstructor(); @@ -127,7 +126,6 @@ try { return iConstructor.newInstance(iArgs); - } catch (InstantiationException ex) { throw new FunctorException("InstantiateFactory: InstantiationException", ex); } catch (IllegalAccessException ex) {