Class FactoryBuilder

java.lang.Object
javax.cache.configuration.FactoryBuilder

public final class FactoryBuilder extends 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 Details

    • FactoryBuilder

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

    • factoryOf

      public static <T> Factory<T> factoryOf(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(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 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