public class Configuration extends AbstractRestObject<Configuration,Configuration> implements ICachedObject
moduleName| Constructor and Description |
|---|
Configuration(String moduleName,
AbstractParameter<?>... parameters)
Constructor that requires a list of parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListeners()
Adds event listeners.
|
String |
changeParameters(Map<String,String> values)
Changes multiple parameters, returning a status message about the change.
|
Configuration |
getAsJson(javax.ws.rs.core.MultivaluedMap<String,String> query)
Returns a JSON representation of this object.
|
Collection<AbstractParameter<?>> |
getParameters()
Retrieves a collection of all parameters.
|
String |
getParameterStringValue(String compositeKey)
Returns the human readable value of the parameter with a specified key.
|
<T> T |
getParameterValue(String compositeKey)
Returns the value of the parameter with a specified key.
|
protected String |
getPrettyPlainText()
Returns a pretty print representation of this object.
|
void |
loadFromDisk()
Attempts to load a configuration file from disk, overwriting the values
of existing parameters, but not adding them if they did not exist before.
|
static <T extends AbstractParameter<?>> |
registerParameter(T parameter)
Convenience function for registering a parameter at the configuration.
|
void |
removeEventListeners()
Removes all event listeners of this class.
|
void |
saveToDisk()
Saves the configuration as a Json file.
|
void |
setCacheFilePath(String path)
Sets the file path to which the configuration can be saved.
|
void |
setParameter(String compositeKey,
String value)
Changes a configuration parameter, returning a status message about the change.
|
static void |
unregisterParameter(AbstractParameter<?> parameter)
Convenience function for unregistering a parameter from the configuration.
|
getAsPlainText, onContextDestroyedpublic Configuration(String moduleName, AbstractParameter<?>... parameters)
moduleName - the name of the serviceparameters - a list parameterspublic static <T extends AbstractParameter<?>> T registerParameter(T parameter) throws IllegalStateException
T - the class of the parameter that is to be registeredparameter - the parameter to be registeredIllegalStateException - thrown if no Configuration existspublic static void unregisterParameter(AbstractParameter<?> parameter)
parameter - the parameter to be unregisteredpublic void addEventListeners()
IEventListeneraddEventListeners in interface IEventListeneraddEventListeners in class AbstractRestObject<Configuration,Configuration>public void removeEventListeners()
IEventListenerremoveEventListeners in interface IEventListenerremoveEventListeners in class AbstractRestObject<Configuration,Configuration>public void setCacheFilePath(String path)
path - a path to a filepublic void saveToDisk()
saveToDisk in interface ICachedObjectpublic void loadFromDisk()
loadFromDisk in interface ICachedObjectpublic <T> T getParameterValue(String compositeKey)
T - the value type of the parametercompositeKey - the parameter category and name, separated by a dotpublic String getParameterStringValue(String compositeKey)
compositeKey - the parameter category and name, separated by a dotpublic void setParameter(String compositeKey, String value) throws IllegalArgumentException
compositeKey - the parameter category and name, separated by a dotvalue - the new value of the parameterIllegalArgumentException - if the compositeKey is empty or does not existpublic String changeParameters(Map<String,String> values) throws IllegalArgumentException
values - a map of key-value parameter pairsIllegalArgumentException - if the values are empty or non of them are validpublic Collection<AbstractParameter<?>> getParameters()
protected String getPrettyPlainText()
AbstractRestObjectgetPrettyPlainText in class AbstractRestObject<Configuration,Configuration>public Configuration getAsJson(javax.ws.rs.core.MultivaluedMap<String,String> query)
AbstractRestObjectgetAsJson in class AbstractRestObject<Configuration,Configuration>query - optional query parameters from the HTTP requestCopyright © 2017–2019. All rights reserved.