public final class OptionalConfiguration extends Object
| Modifier and Type | Field and Description |
|---|---|
static ValueProvider |
DEFAULT_PROVIDER
Default value provider returning Strings from system properties and the system environment.
|
static ValueProvider |
NULLPROVIDER
Default value provider that always returns
null. |
| Modifier and Type | Method and Description |
|---|---|
String |
get(String key)
Access a String value.
|
<T> T |
get(String key,
Class<T> type)
Method that returns the corresponding value, depending on the availability of Tamaya, the
registered provider and evaluation policy.
|
<T> T |
getOrDefault(String key,
Class<T> type,
T defaultValue)
Access a String value.
|
String |
getOrDefault(String key,
String defaultValue)
Access a String value.
|
static OptionalConfiguration |
of(EvaluationPolicy policy)
Returns a default instance, which uses a default provider returning values from system properties and environment
only.
|
static OptionalConfiguration |
of(EvaluationPolicy policy,
ValueProvider provider)
Returns an instance of OptionalConfiguration, which uses the given provider and policy for evaluating the values.
|
public static final ValueProvider DEFAULT_PROVIDER
null is returned.public static final ValueProvider NULLPROVIDER
null.public static OptionalConfiguration of(EvaluationPolicy policy, ValueProvider provider)
policy - the policy how a value should be evaluated depending if Tamaya is available or not.provider - the non Tamaya-based provider to be used to evaluate values.public static OptionalConfiguration of(EvaluationPolicy policy)
policy - the policy how a value should be evaluated depending if Tamaya is available or not.public String get(String key)
key - the key, not null.public String getOrDefault(String key, String defaultValue)
key - the key, not null.defaultValue - the default value, returned if no such key is found in the configuration.public <T> T get(String key, Class<T> type)
T - the type param.key - the key, not null.type - the target type, not null.public <T> T getOrDefault(String key, Class<T> type, T defaultValue)
T - the type param.key - the key, not null.type - the target type, not null.defaultValue - the default value, returned if no such key is found in the configuration.Copyright © 2014–2016 Apache Software Foundation. All rights reserved.