Package org.ametys.runtime.config
Class Config
- java.lang.Object
-
- org.ametys.runtime.config.Config
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
dispose()
Dispose thisConfig
instancestatic boolean
fileExists()
Returns true if the configuration filename exists.static Config
getInstance()
Get the instance of Config using the config file.<T> T
getValue(String name)
Retrieves the typed parameter value<T> T
getValue(String name, boolean useDefaultFromModel, T defaultValue)
Retrieves the typed parameter value, or the default valueMap<String,Object>
getValues()
Retrieves all configuration parameter valuesstatic Map<String,Object>
getValuesAsJSONForClient()
Retrieves all configuration parameter values as JSON objectsstatic void
setFilename(String filename)
Set the configuration filenamestatic void
setInitialized(boolean initialized)
Set the initialization status of the configurationstatic void
setModel(Model model)
Sets the configuration model
-
-
-
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,Object> getValues()
Retrieves all configuration parameter values- Returns:
- the configuration values
-
getValuesAsJSONForClient
public static Map<String,Object> getValuesAsJSONForClient()
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 parameteruseDefaultFromModel
- true to use the default value from the model, false to use the give default valuedefaultValue
- default value used if value is null and useDefaultFromModel is false, or if there is no default value on model- Returns:
- the parameter value
-
-