Class TypedFactory<T>

  • Type Parameters:
    T - The Type which should be created
    Direct Known Subclasses:
    QueryHandlerFactory, TaskFactory, WorkerFactory

    public class TypedFactory<T>
    extends java.lang.Object
    Factory for a Type. Creates an Object from Constructor and Constructor Arguments
    Author:
    f.conrads
    • Constructor Summary

      Constructors 
      Constructor Description
      TypedFactory()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T create​(java.lang.String className, java.lang.Object[] constructorArgs)
      Will create a T Object from a Constructor Object created by the class name and the constructor arguments, be aware that all arguments must be Strings in the constructor.
      T create​(java.lang.String className, java.lang.Object[] constructorArgs, java.lang.Class<?>[] constructorClasses)
      Will create a T Object from a Constructor Object created by the class name and the constructor arguments, and an Array which states each Constructor Object Class
      T create​(java.lang.String className, java.util.Map<java.lang.Object,​java.lang.Object> map)
      Uses the parameter Names and types of a constructor to find the best fitting constructor Only works with jvm -paramaters, otherwise use createAnnotated and annotate the constructors with ParameterNames and set names to the paramater names like .
      T createAnnotated​(java.lang.String className, java.util.Map<java.lang.Object,​java.lang.Object> map)
      Uses the parameter Names and types of a constructor to find the best fitting constructor Uses the ParameterNames annotation of a constructor to get the parameter names like .
      • Methods inherited from class java.lang.Object

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

      • TypedFactory

        public TypedFactory()
    • Method Detail

      • create

        public T create​(java.lang.String className,
                        java.lang.Object[] constructorArgs)
        Will create a T Object from a Constructor Object created by the class name and the constructor arguments, be aware that all arguments must be Strings in the constructor.
        Parameters:
        className - The Class Name of the Implemented T Object
        constructorArgs - constructor arguments (must be Strings), can be safely null
        Returns:
        The T Object created by the Constructor using the constructor args
      • create

        public T create​(java.lang.String className,
                        java.lang.Object[] constructorArgs,
                        java.lang.Class<?>[] constructorClasses)
        Will create a T Object from a Constructor Object created by the class name and the constructor arguments, and an Array which states each Constructor Object Class
        Parameters:
        className - The Class Name of the Implemented T Object
        constructorArgs - constructor arguments (must be Strings), can be safely null
        constructorClasses - The class of each constructor argument
        Returns:
        The T Object created by the Constructor using the constructor args
      • create

        public T create​(java.lang.String className,
                        java.util.Map<java.lang.Object,​java.lang.Object> map)
        Uses the parameter Names and types of a constructor to find the best fitting constructor Only works with jvm -paramaters, otherwise use createAnnotated and annotate the constructors with ParameterNames and set names to the paramater names like . @ParameterNames(names={"a", "b"}) public Constructor(String a, Object b){...}
        Parameters:
        className - The Class Name of the Implemented T Object
        map - key-value pair, whereas key represents the parameter name, where as value will be the value of the instantiation
        Returns:
        The instantiated object or null no constructor was found
      • createAnnotated

        public T createAnnotated​(java.lang.String className,
                                 java.util.Map<java.lang.Object,​java.lang.Object> map)
        Uses the parameter Names and types of a constructor to find the best fitting constructor Uses the ParameterNames annotation of a constructor to get the parameter names like . @ParameterNames(names={"a", "b"}) public Constructor(String a, Object b){...}
        Parameters:
        className - The Class Name of the Implemented T Object
        map - Parameter name - value mapping
        Returns:
        The instantiated object or null no constructor was found