Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.commons.cfg
[Java] Class GrailsConfig

    java.lang.Object
      org.codehaus.groovy.grails.commons.cfg.GrailsConfig

    public class GrailsConfig
    extends java.lang.Object

Type safe abstraction over Grails configuration

Authors:
  Graeme Rocher

Since:
  2.0

Constructor Summary
`GrailsConfig(GrailsApplication grailsApplication)`

Method Summary
`java.lang.Object` | `get(java.lang.String key)` Utility method for retrieving a configuration value.
`java.lang.Object` | `get(java.lang.String key, java.lang.Class type)` Utility method for retrieving a configuration value and performs type checking (i.e. logs a verbose WARN message on type mismatch).
`java.lang.Object` | `get(java.lang.String key, java.lang.Object defaultValue)` Configuration Value lookup with a default value.
`java.lang.Object` | `get(java.lang.String key, java.lang.Object defaultValue, java.util.List 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()`
`java.lang.Object` | `getMandatory(java.lang.String key)` Configuration Value lookup with thows a GrailsConfigurationException when the value is null
`java.lang.Object` | `getMandatory(java.lang.String key, java.util.List allowedValues)` Configuration Value lookup with thows a GrailsConfigurationException when the value is null or not within the allowedValues.

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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()

Constructor Detail

### GrailsConfig

    public GrailsConfig(GrailsApplication grailsApplication)

Method Detail

### get

    @SuppressWarnings("unchecked")
    public java.lang.Object 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

### get

    public java.lang.Object get(java.lang.String key, java.lang.Class 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

### get

    @SuppressWarnings("unchecked")
    public java.lang.Object get(java.lang.String key, java.lang.Object 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`

### get

    public java.lang.Object get(java.lang.String key, java.lang.Object defaultValue, java.util.List 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`

### getAt

    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

### getConfig

    public groovy.util.ConfigObject getConfig()

### getFlatConfig

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

### getMandatory

    @SuppressWarnings("unchecked")
    public java.lang.Object 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

### getMandatory

    @SuppressWarnings("unchecked")
    public java.lang.Object getMandatory(java.lang.String key, java.util.List 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

Groovy Documentation