Class FactoryBuilder.SingletonFactory<T>

  • Type Parameters:
    T - the type of the instance produced by the Factory
    All Implemented Interfaces:
    java.io.Serializable, Factory<T>
    Enclosing class:
    FactoryBuilder

    public static class FactoryBuilder.SingletonFactory<T>
    extends java.lang.Object
    implements Factory<T>, java.io.Serializable
    A Factory that always returns a specific instance. ie: the factory returns a singleton, regardless of the number of times Factory.create() is called.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T instance
      The singleton instance.
      static long serialVersionUID
      The serialVersionUID required for Serializable.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T create()
      Constructs and returns a fully configured instance of T.
      boolean equals​(java.lang.Object other)  
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        public static final long serialVersionUID
        The serialVersionUID required for Serializable.
        See Also:
        Constant Field Values
      • instance

        private T instance
        The singleton instance.
    • Constructor Detail

    • Method Detail

      • create

        public T create()
        Description copied from interface: Factory
        Constructs and returns a fully configured instance of T.
        Specified by:
        create in interface Factory<T>
        Returns:
        an instance of T.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object