org.jjoost.util
Class Factories.SimpleObjectFactory<E>

java.lang.Object
  extended by org.jjoost.util.Factories.SimpleObjectFactory<E>
All Implemented Interfaces:
java.io.Serializable, Factory<E>
Enclosing class:
Factories

public static final class Factories.SimpleObjectFactory<E>
extends java.lang.Object
implements Factory<E>

A simple factory that creates objects of the type of the class provided, providing it has an empty constructor

Author:
b.elliottsmith
See Also:
Serialized Form

Constructor Summary
Factories.SimpleObjectFactory(java.lang.Class<E> clazz)
          Construct a new SimpleObjectFactory for the no-args constructor of the provided type
Factories.SimpleObjectFactory(java.lang.Class<E> clazz, java.lang.Class<?>[] classargs, java.lang.Object[] args)
          Construct a new SimpleObjectFactory for the constructor that matches the types provided
Factories.SimpleObjectFactory(java.lang.Class<E> clazz, java.lang.Object... args)
          Construct a new SimpleObjectFactory for the constructor that matches the types of provided arguments (arguments must be non-null)
 
Method Summary
 E create()
          Returns an object of type E.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factories.SimpleObjectFactory

public Factories.SimpleObjectFactory(java.lang.Class<E> clazz)
                              throws java.lang.SecurityException,
                                     java.lang.NoSuchMethodException,
                                     java.lang.InstantiationException,
                                     java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException
Construct a new SimpleObjectFactory for the no-args constructor of the provided type

Parameters:
clazz - the type to construct
Throws:
java.lang.SecurityException - if clazz.getConstructor throws a SecurityException
java.lang.NoSuchMethodException - if a matching constructor is not found
java.lang.InstantiationException - if an object cannot be constructed using the found constructor
java.lang.IllegalAccessException - if the constructor's access is restricted
java.lang.reflect.InvocationTargetException - if the constructor throws an exception

Factories.SimpleObjectFactory

public Factories.SimpleObjectFactory(java.lang.Class<E> clazz,
                                     java.lang.Object... args)
                              throws java.lang.SecurityException,
                                     java.lang.NoSuchMethodException,
                                     java.lang.InstantiationException,
                                     java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException
Construct a new SimpleObjectFactory for the constructor that matches the types of provided arguments (arguments must be non-null)

Parameters:
clazz - the type to construct
args - the arguments to use for the constructor
Throws:
java.lang.SecurityException - if clazz.getConstructor throws a SecurityException
java.lang.NoSuchMethodException - if a matching constructor is not found
java.lang.InstantiationException - if an object cannot be constructed using the found constructor
java.lang.IllegalAccessException - if the constructor's access is restricted
java.lang.reflect.InvocationTargetException - if the constructor throws an exception

Factories.SimpleObjectFactory

public Factories.SimpleObjectFactory(java.lang.Class<E> clazz,
                                     java.lang.Class<?>[] classargs,
                                     java.lang.Object[] args)
                              throws java.lang.SecurityException,
                                     java.lang.NoSuchMethodException,
                                     java.lang.InstantiationException,
                                     java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException
Construct a new SimpleObjectFactory for the constructor that matches the types provided

Parameters:
clazz - the type to construct
classargs - the types to use to find the constructor
args - the arguments to use for the constructor
Throws:
java.lang.SecurityException - if clazz.getConstructor throws a SecurityException
java.lang.NoSuchMethodException - if a matching constructor is not found
java.lang.InstantiationException - if an object cannot be constructed using the found constructor
java.lang.IllegalAccessException - if the constructor's access is restricted
java.lang.reflect.InvocationTargetException - if the constructor throws an exception
Method Detail

create

public E create()
Description copied from interface: Factory
Returns an object of type E. This method should be thread-safe.

Specified by:
create in interface Factory<E>
Returns:
an object of type E