## grails.util
Class GrailsConfig

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

All Implemented Interfaces:
  groovy.lang.GroovyObject

    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

Since:
  1.1
Author:
  Siegfried Puchbauer

Method Summary

`static

`<T> T`

`

`get(String key)`
Utility method for retrieving a configuration value

`static

`<T> T`

`

`get(String key, Class<T> type)`
Utility method for retrieving a configuration value and performs type checking (i.e. logs a verbose WARN message on type mismatch)

`static

`<T> T`

`

`get(String key, T defaultValue)`
Configuration Value lookup with a default value

`static

`<T> T`

`

`get(String key, T defaultValue, List<T> allowedValues)`
Configuration Value lookup with a default value and a list of allowed values

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

`static

`<T> T`

`

`getMandatory(String key)`
Configuration Value lookup with thows a GrailsConfigurationException when the value is null

`static

`<T> T`

`

`getMandatory(String key, List<T> 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
`getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### get

    public static <T> T get(String key)

  Utility method for retrieving a configuration value

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

### get

    public static <T> T get(String key,
                            Class<T> type)

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

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

### get

    public static <T> T get(String key,
                            T defaultValue)

  Configuration Value lookup with a default value

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

### get

    public static <T> T get(String key,
                            T defaultValue,
                            List<T> allowedValues)

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

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

### getMandatory

    public static <T> T getMandatory(String key)

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

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

### getMandatory

    public static <T> T getMandatory(String key,
                                     List<T> allowedValues)

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

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

### getAt

    public static Object getAt(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

Copyright (c) 2005-2009 The Grails project