Class Config

java.lang.Object
org.ametys.runtime.config.Config

public final class Config extends Object
Bean to read / Write config file
  • Method Details

    • 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.
    • getModel

      public static Model getModel()
      Gets the configuration model
      Returns:
      the model or null if the configuration is not initialized
    • setModel

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

      public long getLastModified()
      Get the last modification of the configuration file
      Returns:
      The last modified or -1 if the file does not exists
    • 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

      Retrieves all configuration parameter values
      Returns:
      the configuration values
    • 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 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