V - The underlying type of the parameter valuepublic abstract class AbstractParameter<V> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
category |
protected String |
key |
protected static org.slf4j.Logger |
LOGGER |
protected Function<String,V> |
mappingFunction |
protected V |
value |
| Constructor and Description |
|---|
AbstractParameter(String key,
String category,
V defaultValue,
Function<String,V> customMappingFunction)
Constructor that uses a custom mapping function.
|
| Modifier and Type | Method and Description |
|---|---|
abstract AbstractParameter<V> |
copy()
Creates an unregistered copy of this parameter.
|
String |
getCategory()
Retrieves the name of the category to which the parameter belongs.
|
String |
getCompositeKey()
Returns a unique key consisting of the category and the parameter key.
|
String |
getKey()
Retrieves the key of the parameter.
|
Function<String,V> |
getMappingFunction()
Retrieves a function that maps a String value to V.
|
String |
getStringValue()
Returns a human readable String of the parameter value.
|
V |
getValue()
Retrieves the parameter value.
|
boolean |
isRegistered()
Returns true if the parameter is registered at the Configuration.
|
void |
loadFromEnvironmentVariables()
Looks for an environment variable that contains the category and key of this parameter
and sets the value to that of the environment variable.
|
void |
setMappingFunction(Function<String,V> mappingFunction)
Sets the function that maps a String value to V.
|
void |
setRegistered(boolean registered)
Determines if the parameter is registered at the Configuration.
|
void |
setValue(String value)
Changes the stored value by parsing a String argument.
|
String |
toString() |
protected static final org.slf4j.Logger LOGGER
protected V value
protected final String key
protected final String category
public AbstractParameter(String key, String category, V defaultValue, Function<String,V> customMappingFunction) throws IllegalArgumentException
key - the unique key of the parameter, which is used to change it via RESTcategory - the category of the parameterdefaultValue - the default valuecustomMappingFunction - a function that maps strings to the parameter valuesIllegalArgumentException - thrown if the key contains invalid characterspublic abstract AbstractParameter<V> copy()
public String getCompositeKey()
public String getStringValue()
public final void setValue(String value) throws IllegalArgumentException
value - a String representation of the new valueIllegalArgumentException - if the value could not be changedpublic void loadFromEnvironmentVariables()
public V getValue()
public String getKey()
public String getCategory()
public Function<String,V> getMappingFunction()
public void setMappingFunction(Function<String,V> mappingFunction)
mappingFunction - a function that maps a String value to Vpublic boolean isRegistered()
public void setRegistered(boolean registered)
registered - true if the parameter is registered at the ConfigurationCopyright © 2017–2019. All rights reserved.