public class DefaultPropertiesProvider extends Object implements PropertiesProvider
PropertiesProvider
based on parsing a yaml-config file.
Per default, the properties are loaded from ./application.yaml in the resource path.
-DconfigFile=/somePath/config.yaml
overrides the default location.
Per default, the active profile is either the first profile with name 'default' or the first profile in the yaml.
-DconfigProfile=<profile-name>
switches the active profile.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultPropertiesProvider.PropertiesRoot
The YAML root representation
|
Constructor and Description |
---|
DefaultPropertiesProvider() |
Modifier and Type | Method and Description |
---|---|
<T> T |
bindPropertyClass(String section,
Class<T> clazz)
Binds the configuration POJO to the specified section
|
String |
getFeatureName() |
<T> T |
getProperty(String key,
Class<T> clazz,
T defaultValue)
Returns the value of the property with given key as given type
asClazz . |
String |
getProperty(String key,
String defaultValue)
Returns the value of the property with given key as
String . |
boolean |
isActiveFeature()
Checks if the feature is activated
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperty, getProperty, hasProperty
public <T> T bindPropertyClass(String section, Class<T> clazz)
PropertiesProvider
bindPropertyClass
in interface PropertiesProvider
T
- the type of the POJOsection
- the properties sectionclazz
- the class of the POJOpublic String getProperty(String key, String defaultValue)
PropertiesProvider
String
.
Returns the specified default value if key is not existing.getProperty
in interface PropertiesProvider
key
- The key of the propertydefaultValue
- The default value if the key is not presentString
value or defaultValue
if not definedpublic <T> T getProperty(String key, Class<T> clazz, T defaultValue)
PropertiesProvider
asClazz
.
Returns the specified default value if key is not existing.getProperty
in interface PropertiesProvider
T
- the type of the property valuekey
- The key of the propertyclazz
- The type of the property valuedefaultValue
- The default value if the key is not presentdefaultValue
if not definedpublic boolean isActiveFeature()
Feature
isActiveFeature
in interface Feature
public String getFeatureName()
getFeatureName
in interface Feature
Copyright © 2020. All rights reserved.