Package cdc.args

Class AbstractFactory<T>

java.lang.Object
cdc.args.AbstractFactory<T>
Type Parameters:
T - Type of created objects.
All Implemented Interfaces:
Factory<T>
Direct Known Subclasses:
AutoFactory

public abstract class AbstractFactory<T> extends Object implements Factory<T>
Base class for factory implementation.
Author:
Damien Carbonne
  • Constructor Details

    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass, Args meta, List<FormalArgs> creationFormalArgs)
      Creates a factory with a list of possible tuples for creation.
      Parameters:
      objectClass - The class of created objects.
      meta - The meta parameters associated to this factory.
      creationFormalArgs - A list of tuples of formal arguments that can be used for creation.
    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass, List<FormalArgs> creationFormalArgs)
    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass, Args meta, FormalArgs... creationFormalArgs)
      Creates a factory with an array of possible tuples for creation.
      Parameters:
      objectClass - The class of created objects.
      meta - The meta parameters associated to this factory.
      creationFormalArgs - An array of tuples of formal arguments that can be used for creation.
    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass, FormalArgs... creationFormalArgs)
    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass, Args meta)
      Creates a factory that does not accept any argument for creation.
      Parameters:
      meta - The meta parameters associated to this factory.
      objectClass - The class of created objects.
    • AbstractFactory

      protected AbstractFactory(Class<T> objectClass)
      Creates a factory that does not accept any argument for creation.
      Parameters:
      objectClass - The class of created objects.
  • Method Details

    • getObjectClass

      public final Class<T> getObjectClass()
      Specified by:
      getObjectClass in interface Factory<T>
      Returns:
      The class of built objects.
    • getMeta

      public final Args getMeta()
      Specified by:
      getMeta in interface Factory<T>
      Returns:
      The meta data associated to this factory.
    • getCreationFormalArgsList

      public final List<FormalArgs> getCreationFormalArgsList()
      Description copied from interface: Factory
      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.

      Specified by:
      getCreationFormalArgsList in interface Factory<T>
      Returns:
      A list of supported creation arguments.
    • create

      protected abstract T create(Args args, FormalArgs fargs)
      Creates an object.

      This is the creation method that must be implemented.

      Parameters:
      args - The effective arguments.
      fargs - The formal arguments that match the effective ones.
      Returns:
      The create object.
    • create

      public final T create(Args args)
      Description copied from interface: Factory
      Creates a T instance.
      Specified by:
      create in interface Factory<T>
      Parameters:
      args - The creation arguments.
      Returns:
      A new T instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object