Package adams.core

Class NewInstance

    • Field Detail

      • m_Singleton

        protected static NewInstance m_Singleton
        the singleton.
      • m_Properties

        protected Properties m_Properties
        the placeholders.
      • m_Classnames

        protected Set<String> m_Classnames
        the classnames that have a custom constructor.
      • m_Classes

        protected Set<Class> m_Classes
        the classes that have a custom constructor.
      • m_DefaultValues

        protected Map<Class,​Object[]> m_DefaultValues
        the constructor default values.
    • Method Detail

      • initialize

        protected void initialize()
        loads the props file and interpretes it.
      • hasCustomInstantiation

        public boolean hasCustomInstantiation​(String classname)
        Checks whether the classname is registered with a custom instantiation.
        Parameters:
        classname - the classname to check
        Returns:
        true if custom instantiation
      • hasCustomInstantiation

        public boolean hasCustomInstantiation​(Class cls)
        Checks whether the class is registered with a custom instantiation.
        Parameters:
        cls - the class to check
        Returns:
        true if custom instantiation
      • newObject

        public Object newObject​(String classname)
        Returns a new object instance.
        Parameters:
        classname - the class to instantiate
        Returns:
        the instance, null if failed to instantiate
      • newObject

        public Object newObject​(String classname,
                                boolean quiet)
        Returns a new object instance.
        Parameters:
        classname - the class to instantiate
        quiet - whether to suppress error messages
        Returns:
        the instance, null if failed to instantiate
      • configure

        protected boolean configure​(Class cls)
                             throws Exception
        Configures constructor and default values.
        Parameters:
        cls - the class to configure
        Returns:
        true if successfully configured (or already present)
        Throws:
        Exception - if configuration fails (eg instantiating a custom class)
      • newObject

        public Object newObject​(Class cls)
        Returns a new object instance.
        Parameters:
        cls - the class to instantiate
        Returns:
        the instance, null if failed to instantiate
      • newObject

        public Object newObject​(Class cls,
                                boolean quiet)
        Returns a new object instance.
        Parameters:
        cls - the class to instantiate
        quiet - whether to suppress error messages
        Returns:
        the instance, null if failed to instantiate
      • getSingleton

        public static NewInstance getSingleton()
        Returns the singleton instance of the NewInstance.
        Returns:
        the singleton
      • newInstance

        public static Object newInstance​(String classname)
        Returns a new object instance.
        Parameters:
        classname - the class to instantiate
        Returns:
        the instance, null if failed to instantiate
      • newInstance

        public static Object newInstance​(String classname,
                                         boolean quiet)
        Returns a new object instance.
        Parameters:
        classname - the class to instantiate
        quiet - whether to suppress error messages
        Returns:
        the instance, null if failed to instantiate
      • newInstance

        public static Object newInstance​(Class cls)
        Returns a new object instance.
        Parameters:
        cls - the class to instantiate
        Returns:
        the instance, null if failed to instantiate
      • newInstance

        public static Object newInstance​(Class cls,
                                         boolean quiet)
        Returns a new object instance.
        Parameters:
        cls - the class to instantiate
        quiet - whether to suppress error messages
        Returns:
        the instance, null if failed to instantiate