com.holonplatform.spring.internal

## Class DefaultEnvironmentConfigPropertyProvider

- java.lang.Object
- - com.holonplatform.spring.internal.DefaultEnvironmentConfigPropertyProvider

- All Implemented Interfaces:
    ConfigPropertyProvider, EnvironmentConfigPropertyProvider

      public class DefaultEnvironmentConfigPropertyProvider
      extends Object
      implements EnvironmentConfigPropertyProvider

  A `ConfigPropertyProvider` using Spring context `Environment` as configuration property source.
  Since:
    5.0.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultEnvironmentConfigPropertyProvider(org.springframework.core.env.Environment environment)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsProperty(String key)` Return whether the given property key is available, i.e. the property key is present and the value for the given key is not `null`.
    `org.springframework.core.env.Environment` | `getEnvironment()` Gets the Spring context Environment
    `<T> T` | `getProperty(String key, Class<T> targetType)` Return the property value associated with the given key and try to convert property value to given target type.
    `Stream<String>` | `getPropertyNames()` Returns a Stream of all available property names

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.spring.EnvironmentConfigPropertyProvider

      `create`

    - ### Methods inherited from interface com.holonplatform.core.config.ConfigPropertyProvider

      `prefixed, using, using, using, using, using, usingSystemProperties`

- - ### Constructor Detail

    - #### DefaultEnvironmentConfigPropertyProvider

          public DefaultEnvironmentConfigPropertyProvider(org.springframework.core.env.Environment environment)

      Constructor
      Parameters:
        `environment` - Spring context Environment (not null)

  - ### Method Detail

    - #### getEnvironment

          public org.springframework.core.env.Environment getEnvironment()

      Gets the Spring context Environment
      Specified by:
        `getEnvironment` in interface `EnvironmentConfigPropertyProvider`
      Returns:
        the Spring context Environment

    - #### containsProperty

          public boolean containsProperty(String key)

      Description copied from interface: `ConfigPropertyProvider`
      Return whether the given property key is available, i.e. the property key is present and the value for the given key is not `null`.
      Specified by:
        `containsProperty` in interface `ConfigPropertyProvider`
      Parameters:
        `key` - Property key (not null)
      Returns:
        `true` if property exists and has not `null` value

    - #### getProperty

          public <T> T getProperty(String key,
                                   Class<T> targetType)
                            throws IllegalArgumentException

      Description copied from interface: `ConfigPropertyProvider`
      Return the property value associated with the given key and try to convert property value to given target type.
      Specified by:
        `getProperty` in interface `ConfigPropertyProvider`
      Type Parameters:
        `T` - Expected property and result type
      Parameters:
        `key` - the property name to resolve (not null)
        `targetType` - the expected type of the property value
      Returns:
        Property value or `null` if the key cannot be resolved
      Throws:
        `IllegalArgumentException` - If property value cannot be converted to target type

    - #### getPropertyNames

          public Stream<String> getPropertyNames()
                                          throws UnsupportedOperationException

      Description copied from interface: `ConfigPropertyProvider`
      Returns a Stream of all available property names
      Specified by:
        `getPropertyNames` in interface `ConfigPropertyProvider`
      Returns:
        Property names stream
      Throws:
        `UnsupportedOperationException` - If this operation is not supported by concrete implementation

Copyright © 2019 The Holon Platform. All rights reserved.