Package: org.codehaus.groovy.grails.commons.cfg

## [Java] Class GrailsConfig

- org.codehaus.groovy.grails.commons.cfg.GrailsConfig

- Type safe abstraction over Grails configuration

  Authors:
    Graeme Rocher
  Since:
    2.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `SPRING_PLACEHOLDER_PREFIX` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `GrailsConfig (GrailsApplication grailsApplication)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `T` | `get(java.lang.String key)` Utility method for retrieving a configuration value.
    `T` | `get(java.lang.String key, java.lang.Class<T> type)` Utility method for retrieving a configuration value and performs type checking (i.e. logs a verbose WARN message on type mismatch).
    `T` | `get(java.lang.String key, T defaultValue)` Configuration Value lookup with a default value.
    `T` | `get(java.lang.String key, T defaultValue, java.util.List<T> allowedValues)` Configuration Value lookup with a default value and a list of allowed values.
    `java.lang.Object` | `getAt(java.lang.Object key)` Configuration Value lookup for Groovy's array-like property access `GrailsConfig['my.config.key']`
    `groovy.util.ConfigObject` | `getConfig()`
    `java.util.Map` | `getFlatConfig()`
    `T` | `getMandatory(java.lang.String key)` Configuration Value lookup with thows a GrailsConfigurationException when the value is null
    `T` | `getMandatory(java.lang.String key, java.util.List<T> allowedValues)` Configuration Value lookup with thows a GrailsConfigurationException when the value is null or not within the allowedValues.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### public static final java.lang.String SPRING_PLACEHOLDER_PREFIX

  - ### Constructor Detail

    - #### public GrailsConfig(GrailsApplication grailsApplication)

  - ### Method Detail

    - #### @java.lang.SuppressWarnings("unchecked") public T get(java.lang.String key)

      Utility method for retrieving a configuration value.

      Parameters:
        `key` - the flattened key
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig

    - #### public T get(java.lang.String key, java.lang.Class<T> type)

      Utility method for retrieving a configuration value and performs type checking (i.e. logs a verbose WARN message on type mismatch).

      Parameters:
        `key` - the flattened key
        `type` - the required type
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig

    - #### @java.lang.SuppressWarnings("unchecked") public T get(java.lang.String key, T defaultValue)

      Configuration Value lookup with a default value.

      Parameters:
        `key` - the flattened key
        `defaultValue` - the default value
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig if not null, otherwise the `defaultValue`

    - #### public T get(java.lang.String key, T defaultValue, java.util.List<T> allowedValues)

      Configuration Value lookup with a default value and a list of allowed values.

      Parameters:
        `key` - the flattened key
        `defaultValue` - the default value
        `allowedValues` - List of allowed values
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig, if it is contained in `allowedValues`, otherwise the `defaultValue`

    - #### public java.lang.Object getAt(java.lang.Object key)

      Configuration Value lookup for Groovy's array-like property access `GrailsConfig['my.config.key']`

      Parameters:
        `key` - the config key
      Returns:
        the configured value

    - #### public groovy.util.ConfigObject getConfig()

    - #### @java.lang.SuppressWarnings("rawtypes") public java.util.Map getFlatConfig()

    - #### @java.lang.SuppressWarnings("unchecked") public T getMandatory(java.lang.String key)

      Configuration Value lookup with thows a GrailsConfigurationException when the value is null

      Parameters:
        `key` - the flattened key
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig

    - #### @java.lang.SuppressWarnings("unchecked") public T getMandatory(java.lang.String key, java.util.List<T> allowedValues)

      Configuration Value lookup with thows a GrailsConfigurationException when the value is null or not within the allowedValues.

      Parameters:
        `key` - the flattened key
        `allowedValues` - List of allowed values
        `` - the type parameter
      Returns:
        the value retrieved by ConfigurationHolder.flatConfig