Class Config


  • public final class Config
    extends Object
    Bean to read / Write config file
    • Constructor Detail

    • Method Detail

      • getInstance

        public static Config getInstance()
        Get the instance of Config using the config file.
        Returns:
        An instance of Config containing config file values and definition, or null if config file cannot be read.
      • setModel

        public static void setModel​(Model model)
        Sets the configuration model
        Parameters:
        model - the model to set
      • setInitialized

        public static void setInitialized​(boolean initialized)
        Set the initialization status of the configuration
        Parameters:
        initialized - the initialization status of the configuration
      • setFilename

        public static void setFilename​(String filename)
        Set the configuration filename
        Parameters:
        filename - Name with path of the configuration file
      • fileExists

        public static boolean fileExists()
        Returns true if the configuration filename exists.
        Returns:
        true if the configuration filename exists.
      • getValues

        public Map<String,​ObjectgetValues()
        Retrieves all configuration parameter values
        Returns:
        the configuration values
      • getValuesAsJSONForClient

        public static Map<String,​ObjectgetValuesAsJSONForClient()
        Retrieves all configuration parameter values as JSON objects
        Returns:
        the configuration values as JSON objects
      • getValue

        public <T> T getValue​(String name)
        Retrieves the typed parameter value
        Type Parameters:
        T - type of the value to retrieve
        Parameters:
        name - name of the configuration parameter
        Returns:
        the parameter value
      • getValue

        public <T> T getValue​(String name,
                              boolean useDefaultFromModel,
                              T defaultValue)
        Retrieves the typed parameter value, or the default value
        Type Parameters:
        T - type of the value to retrieve
        Parameters:
        name - name of the configuration parameter
        useDefaultFromModel - true to use the default value from the model, false to use the give default value
        defaultValue - default value used if value is null and useDefaultFromModel is false, or if there is no default value on model
        Returns:
        the parameter value
      • dispose

        public static void dispose()
        Dispose this Config instance