org.springframework.core.env

## Interface PropertyResolver

All Known Subinterfaces:
  ConfigurableEnvironment, ConfigurablePropertyResolver, ConfigurableWebEnvironment, Environment

All Known Implementing Classes:
  AbstractEnvironment, AbstractPropertyResolver, MockEnvironment, PropertySourcesPropertyResolver, StandardEnvironment, StandardPortletEnvironment, StandardServletEnvironment

    public interface PropertyResolver

Interface for resolving properties against any underlying source.

Since:
  3.1
Author:
  Chris Beams
See Also:
  `Environment`, `PropertySourcesPropertyResolver`

### Method Summary

Methods
`boolean` `containsProperty(String key)` Return whether the given property key is available for resolution, i.e., the value for the given key is not `null`.
`String` `getProperty(String key)` Return the property value associated with the given key, or `null` if the key cannot be resolved.
`<T> T` `getProperty(String key, Class<T> targetType)` Return the property value associated with the given key, or `null` if the key cannot be resolved.
`<T> T` `getProperty(String key, Class<T> targetType, T defaultValue)` Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.
`String` `getProperty(String key, String defaultValue)` Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.
`<T> Class<T>` `getPropertyAsClass(String key, Class<T> targetType)` Convert the property value associated with the given key to a `Class` of type `T` or `null` if the key cannot be resolved.
`String` `getRequiredProperty(String key)` Return the property value associated with the given key, converted to the given targetType (never `null`).
`<T> T` `getRequiredProperty(String key, Class<T> targetType)` Return the property value associated with the given key, converted to the given targetType (never `null`).
`String` `resolvePlaceholders(String text)` Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by `getProperty(java.lang.String)`.
`String` `resolveRequiredPlaceholders(String text)` Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by `getProperty(java.lang.String)`.

### Method Detail

#### containsProperty

    boolean containsProperty(String key)

Return whether the given property key is available for resolution, i.e., the value for the given key is not `null`.

#### getProperty

    String getProperty(String key)

Return the property value associated with the given key, or `null` if the key cannot be resolved.

Parameters:
  `key` - the property name to resolve
See Also:
  `getProperty(String, String)`, `getProperty(String, Class)`, `getRequiredProperty(String)`

#### getProperty

    String getProperty(String key,
                     String defaultValue)

Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.

Parameters:
  `key` - the property name to resolve
  `defaultValue` - the default value to return if no value is found
See Also:
  `getRequiredProperty(String)`, `getProperty(String, Class)`

#### getProperty

    <T> T getProperty(String key,
                    Class<T> targetType)

Return the property value associated with the given key, or `null` if the key cannot be resolved.

Parameters:
  `key` - the property name to resolve
  `targetType` - the expected type of the property value
See Also:
  `getRequiredProperty(String, Class)`

#### getProperty

    <T> T getProperty(String key,
                    Class<T> targetType,
                    T defaultValue)

Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.

Parameters:
  `key` - the property name to resolve
  `targetType` - the expected type of the property value
  `defaultValue` - the default value to return if no value is found
See Also:
  `getRequiredProperty(String, Class)`

#### getPropertyAsClass

    <T> Class<T> getPropertyAsClass(String key,
                                  Class<T> targetType)

Convert the property value associated with the given key to a `Class` of type `T` or `null` if the key cannot be resolved.

Throws:
  `ConversionException` - if class specified by property value cannot be found or loaded or if targetType is not assignable from class specified by property value
See Also:
  `getProperty(String, Class)`

#### getRequiredProperty

    String getRequiredProperty(String key)
                               throws IllegalStateException

Return the property value associated with the given key, converted to the given targetType (never `null`).

Throws:
  `IllegalStateException` - if the key cannot be resolved
See Also:
  `getRequiredProperty(String, Class)`

#### getRequiredProperty

    <T> T getRequiredProperty(String key,
                            Class<T> targetType)
                          throws IllegalStateException

Return the property value associated with the given key, converted to the given targetType (never `null`).

Throws:
  `IllegalStateException` - if the given key cannot be resolved

#### resolvePlaceholders

    String resolvePlaceholders(String text)

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by `getProperty(java.lang.String)`. Unresolvable placeholders with no default value are ignored and passed through unchanged.

Parameters:
  `text` - the String to resolve
Returns:
  the resolved String (never `null`)
Throws:
  `IllegalArgumentException` - if given text is `null`
See Also:
  `resolveRequiredPlaceholders(java.lang.String)`, `SystemPropertyUtils.resolvePlaceholders(String)`

#### resolveRequiredPlaceholders

    String resolveRequiredPlaceholders(String text)
                                       throws IllegalArgumentException

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by `getProperty(java.lang.String)`. Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.

Returns:
  the resolved String (never `null`)
Throws:
  `IllegalArgumentException` - if given text is `null`
  `IllegalArgumentException` - if any placeholders are unresolvable
See Also:
  `SystemPropertyUtils.resolvePlaceholders(String, boolean)`