Package cdc.args
Interface Factory<T>
- Type Parameters:
T- Type of created objects.
- All Known Implementing Classes:
AbstractFactory,AutoFactory,Singleton
public interface Factory<T>
Interface dedicated to objects creation.
- Author:
- Damien Carbonne
-
Method Summary
Modifier and TypeMethodDescriptiondefault Tcreate()Creates aTinstance.Creates aTinstance.Returns a list of supported creation arguments.default ArgsgetMeta()static <E> Factory<E>singleton(E object) Creates a Singleton factory with no (empty) meta data.static <E> Factory<E>Creates a Singleton factory.static <E> Factory<E>Creates a Singleton factory with no (empty) meta data.static <E> Factory<E>Creates a Singleton factory.
-
Method Details
-
getObjectClass
- Returns:
- The class of built objects.
-
getMeta
- Returns:
- The meta data associated to this factory.
-
getCreationFormalArgsList
List<FormalArgs> getCreationFormalArgsList()Returns a list of supported creation arguments.This list must not be empty.
If creation does not need any arguments, a list containing FormalArgs.NO_FARGS should be returned.- Returns:
- A list of supported creation arguments.
-
create
Creates aTinstance.- Parameters:
args- The creation arguments.- Returns:
- A new
Tinstance. - Throws:
IllegalArgumentException- Whenargsis not valid.
-
create
Creates aTinstance.Uses empty args.
- Returns:
- A new
Tinstance. - Throws:
IllegalArgumentException- When empty args is not valid.
-
singleton
Creates a Singleton factory.- Type Parameters:
E- The created objects type.- Parameters:
objectClass- The created objects class.object- The object that will be returned when a creation is asked.meta- The meta data associated to the created factory.- Returns:
- A Factory that will always return
objectwhen a creation is asked.
-
singleton
Creates a Singleton factory with no (empty) meta data.- Type Parameters:
E- The created objects type.- Parameters:
objectClass- The created objects class.object- The object that will be returned when a creation is asked.- Returns:
- A Factory that will always return
objectwhen a creation is asked.
-
singleton
Creates a Singleton factory.The class of created objects is that of
object.
Meta data can be associated to the factory.- Type Parameters:
E- The created objects type.- Parameters:
object- The object that will be returned when a creation is asked.meta- The meta data associated to the created factory.- Returns:
- A Factory that will always return
objectwhen a creation is asked.
-
singleton
Creates a Singleton factory with no (empty) meta data.The class of created objects is that of
object.- Type Parameters:
E- The created objects type.- Parameters:
object- The object that will be returned when a creation is asked.- Returns:
- A Factory that will always return
objectwhen a creation is asked.
-