public class FakeConfiguration extends Object implements org.wisdom.api.configuration.Configuration
| Constructor and Description |
|---|
FakeConfiguration(Map<String,Object> map) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
asMap() |
Properties |
asProperties() |
String |
get(String key)
Get a String property or null if it is not there.
|
<T> T |
get(String key,
Class<T> clazz)
Get a custom type property or null if it's not there.
|
<T> T |
get(String key,
Class<T> clazz,
String defaultValueAsString)
Get a custom type property or the given default value if it's not there.
|
<T> T |
get(String key,
Class<T> clazz,
T defaultValue)
Get a custom type property or the given default value if it's not there.
|
Boolean |
getBoolean(String key)
Get a property as Boolean or null if not there or if the property is not an integer.
|
Boolean |
getBooleanOrDie(String key)
The "die" method forces this key to be set.
|
Boolean |
getBooleanWithDefault(String key,
Boolean defaultValue)
Get a Boolean property or a default value when property cannot be found
in any configuration file.
|
Long |
getBytes(String key)
Gets a property for a size in bytes.
|
Long |
getBytes(String key,
long defaultValue)
Gets a property for a size in bytes.
|
org.wisdom.api.configuration.Configuration |
getConfiguration(String prefix)
Gets a sub-configuration (instance of
FakeConfiguration) stored at the key 'prefix' |
Double |
getDouble(String key)
Get a property as Double or null if not there / or if the property is not an integer.
|
Double |
getDoubleOrDie(String key)
The "die" method forces this key to be set.
|
Double |
getDoubleWithDefault(String key,
Double defaultValue)
Get a Double property or a default value when property cannot be found
in any configuration file.
|
Long |
getDuration(String key,
TimeUnit unit)
Gets a property for a duration.
|
Long |
getDuration(String key,
TimeUnit unit,
long defaultValue)
Gets a property for a duration.
|
Integer |
getInteger(String key)
Get a property as Integer or null if not there / or if the property is not an integer.
|
Integer |
getIntegerOrDie(String key)
The "die" method forces this key to be set.
|
Integer |
getIntegerWithDefault(String key,
Integer defaultValue)
Get a Integer property or a default value when property cannot be found
in any configuration file.
|
List<String> |
getList(String key)
Gets the list of values.
|
Long |
getLong(String key)
Get a property as Long or null if not there or if the property is not a long.
|
Long |
getLongOrDie(String key)
The "die" method forces this key to be set.
|
Long |
getLongWithDefault(String key,
Long defaultValue)
Get a Long property or a default value when property cannot be found
in any configuration file.
|
String |
getOrDie(String key)
The "die" method forces this key to be set.
|
<T> T |
getOrDie(String key,
Class<T> clazz)
Get a custom type property.
|
String[] |
getStringArray(String key)
Gets the array of values.
|
String |
getWithDefault(String key,
String defaultValue)
Get a String property or a default value when property cannot be found in
any configuration file.
|
boolean |
has(String key)
Checks whether the configuration object define a value at the given name / path.
|
public org.wisdom.api.configuration.Configuration getConfiguration(String prefix)
FakeConfiguration) stored at the key 'prefix'getConfiguration in interface org.wisdom.api.configuration.Configurationprefix - the keypublic boolean has(String key)
has in interface org.wisdom.api.configuration.Configurationkey - the key / pathtrue if the configuration has a non-null value, false otherwisepublic String get(String key)
get in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public <T> T get(String key, Class<T> clazz)
get in interface org.wisdom.api.configuration.Configurationkey - the key the key used in the configuration file.clazz - the class of the object (must match the stored object)null if not therepublic <T> T getOrDie(String key, Class<T> clazz)
org.wisdom.api.content.ParameterFactories strategy. This "die" method forces this key to be set.
Otherwise a runtime exception will be thrown.getOrDie in interface org.wisdom.api.configuration.Configurationkey - the key the key used in the configuration file.clazz - the class of the object to createRuntimeException is thrown.public <T> T get(String key, Class<T> clazz, T defaultValue)
org.wisdom.api.content.ParameterFactories strategy.get in interface org.wisdom.api.configuration.Configurationkey - the key the key used in the configuration file.clazz - the class of the object to createdefaultValue - the object returned if the property is missingpublic <T> T get(String key, Class<T> clazz, String defaultValueAsString)
org.wisdom.api.content.ParameterFactories strategy.get in interface org.wisdom.api.configuration.Configurationkey - the key the key used in the configuration file.clazz - the class of the object to createdefaultValueAsString - the 'string' format of the object returned if the property is missing. The object
is built using the parameter converters service.public String getWithDefault(String key, String defaultValue)
getWithDefault in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - Default value returned, when value cannot be found in
configuration.public Integer getInteger(String key)
getInteger in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Integer getIntegerWithDefault(String key, Integer defaultValue)
getIntegerWithDefault in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - Default value returned, when value cannot be found in
configuration.public Double getDouble(String key)
getDouble in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Double getDoubleWithDefault(String key, Double defaultValue)
getDoubleWithDefault in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - Default value returned, when value cannot be found in
configuration.public Boolean getBoolean(String key)
getBoolean in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Boolean getBooleanWithDefault(String key, Boolean defaultValue)
getBooleanWithDefault in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - Default value returned, when value cannot be found in
configuration.public Long getLong(String key)
getLong in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Long getLongWithDefault(String key, Long defaultValue)
getLongWithDefault in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - Default value returned, when value cannot be found in
configuration.public Long getLongOrDie(String key)
getLongOrDie in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Boolean getBooleanOrDie(String key)
getBooleanOrDie in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Integer getIntegerOrDie(String key)
getIntegerOrDie in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Double getDoubleOrDie(String key)
getDoubleOrDie in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public String getOrDie(String key)
getOrDie in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.public Long getDuration(String key, TimeUnit unit)
Are supported:
No conversion in this implementation !
Data must be a long
getDuration in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.unit - the time unitnull if not found.public Long getDuration(String key, TimeUnit unit, long defaultValue)
Are supported:
No conversion in this implementation !
getDuration in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.unit - the time unitdefaultValue - the default value to return if the configuration does not contain the given keydefaultValue if not found.public Long getBytes(String key)
For single bytes, exactly these strings are supported:
* No conversion in this implementation !
getBytes in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.null if not found.public Long getBytes(String key, long defaultValue)
For single bytes, exactly these strings are supported:
getBytes in interface org.wisdom.api.configuration.Configurationkey - the key used in the configuration file.defaultValue - the default value to return if the configuration does not contain the given keydefaultValue if not found.public String[] getStringArray(String key)
getStringArray in interface org.wisdom.api.configuration.Configurationkey - the keypublic List<String> getList(String key)
getList in interface org.wisdom.api.configuration.Configurationkey - the keypublic Properties asProperties()
asProperties in interface org.wisdom.api.configuration.ConfigurationCopyright © 2013–2015 Wisdom Framework. All rights reserved.