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

## grails.util
[Java] Class GrailsConfig

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          grails.util.GrailsConfig

    @SuppressWarnings("rawtypes")
    public class GrailsConfig
    extends groovy.lang.GroovyObjectSupport

General purpose Grails Configuration Utility for retieving configuration options with the ability to log warnings on type/constraint mismatch.

Authors:
  Siegfried Puchbauer

Since:
  1.1

Method Summary
`static T` | `get(java.lang.String key)` Utility method for retrieving a configuration value.
`static T` | `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).
`static T` | `get(java.lang.String key, T defaultValue)` Configuration Value lookup with a default value.
`static T` | `get(java.lang.String key, T defaultValue, java.util.List allowedValues)` Configuration Value lookup with a default value and a list of allowed values.
`static java.lang.Object` | `getAt(java.lang.Object key)` Configuration Value lookup for Groovy's array-like property access `GrailsConfig['my.config.key']`
`static T` | `getMandatory(java.lang.String key)` Configuration Value lookup with thows a GrailsConfigurationException when the value is null
`static T` | `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 groovy.lang.GroovyObjectSupport
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll()

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()

Method Detail

### get

    @SuppressWarnings("unchecked")
    public static 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

### get

    public static T 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 static 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`

### get

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

### getMandatory

    @SuppressWarnings("unchecked")
    public static 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

### getMandatory

    @SuppressWarnings("unchecked")
    public static T 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