Class FactoryBuilder


  • public final class FactoryBuilder
    extends java.lang.Object
    A convenience class that defines generically typed static methods to aid in the building of Factory instances.

    Factory is used by MutableConfiguration to avoid adding non-Serializable instances that would assume usage in the local JVM.

    Two styles of builder are available:

    • those taking a Class or className. A new instance will be created by the Factory
    • those taking a Serializable instance. That instance will be created by the Factory. As the instance is Serializable it no assumption of usage in the local JVM is implied.
    Factory instances can also be created in other ways.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FactoryBuilder()
      A private constructor to prevent instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Factory<T> factoryOf​(java.lang.Class<T> clazz)
      Constructs a Factory that will produce factory instances of the specified class.
      static <T> Factory<T> factoryOf​(java.lang.String className)
      Constructs a Factory that will produce factory instances of the specified class.
      static <T extends java.io.Serializable>
      Factory<T>
      factoryOf​(T instance)
      Constructs a Factory that will return the specified factory Serializable instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FactoryBuilder

        private FactoryBuilder()
        A private constructor to prevent instantiation.
    • Method Detail

      • factoryOf

        public static <T> Factory<T> factoryOf​(java.lang.Class<T> clazz)
        Constructs a Factory that will produce factory instances of the specified class.

        The specified class must have a no-args constructor.

        Type Parameters:
        T - the type of the instances produced by the Factory
        Parameters:
        clazz - the class of instances to be produced by the returned Factory
        Returns:
        a Factory for the specified clazz
      • factoryOf

        public static <T> Factory<T> factoryOf​(java.lang.String className)
        Constructs a Factory that will produce factory instances of the specified class.

        The specified class must have a no-args constructor.

        Type Parameters:
        T - the type of the instances produced by the Factory
        Parameters:
        className - the class of instances to be produced by the returned Factory
        Returns:
        a Factory for the specified clazz
      • factoryOf

        public static <T extends java.io.Serializable> Factory<T> factoryOf​(T instance)
        Constructs a Factory that will return the specified factory Serializable instance.

        If T is not Serializable use factoryOf(Class) or factoryOf(String).

        Type Parameters:
        T - the type of the instances returned
        Parameters:
        instance - the Serializable instance the Factory will return
        Returns:
        a Factory for the instance