Package cdc.args

Class Singleton<T>

  • Type Parameters:
    T - Type of created objects.
    All Implemented Interfaces:
    Factory<T>

    public class Singleton<T>
    extends Object
    implements Factory<T>
    Implementation of Factory dedicated to singletons.
    Author:
    Damien Carbonne
    • Constructor Detail

      • Singleton

        public Singleton​(Class<T> objectClass,
                         T object,
                         Args meta)
        Creates a Singleton factory.
        Parameters:
        objectClass - Class of created objects.
        object - The singleton object to use. It is this instance that will be returned each time a creation is asked.
        meta - The meta data associated to this factory.
      • Singleton

        public Singleton​(T object,
                         Args meta)
        Creates a Singleton factory.

        Class of created objects is the class of object.

        Parameters:
        object - The singleton object to use. It is this instance that will be returned each time a creation is asked.
        meta - The meta data associated to this factory.
    • Method Detail

      • getObjectClass

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

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

        public 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

        public 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.