S - type of subject@Beta public abstract class Config<S> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected com.fasterxml.jackson.databind.node.ArrayNode |
array |
protected ConfigApplyDelegate |
delegate |
protected String |
key |
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
protected com.fasterxml.jackson.databind.JsonNode |
node |
protected com.fasterxml.jackson.databind.node.ObjectNode |
object |
protected S |
subject |
| Constructor and Description |
|---|
Config() |
| Modifier and Type | Method and Description |
|---|---|
void |
apply()
Applies any configuration changes made via this configuration.
|
protected boolean |
get(String name,
boolean defaultValue)
Gets the specified property as a boolean.
|
protected double |
get(String name,
double defaultValue)
Gets the specified property as a double.
|
protected <E extends Enum<E>> |
get(String name,
E defaultValue,
Class<E> enumClass)
Gets the specified property as an enum.
|
protected int |
get(String name,
int defaultValue)
Gets the specified property as an integer.
|
protected long |
get(String name,
long defaultValue)
Gets the specified property as a long.
|
protected String |
get(String name,
String defaultValue)
Gets the specified property as a string.
|
protected <T> List<T> |
getList(String name,
java.util.function.Function<String,T> function)
Gets the specified array property as a list of items.
|
void |
init(S subject,
String key,
com.fasterxml.jackson.databind.JsonNode node,
com.fasterxml.jackson.databind.ObjectMapper mapper,
ConfigApplyDelegate delegate)
Initializes the configuration behaviour with necessary context.
|
String |
key()
Returns the configuration key.
|
com.fasterxml.jackson.databind.JsonNode |
node()
Returns the JSON node that contains the configuration data.
|
protected Config<S> |
setOrClear(String name,
Boolean value)
Sets the specified property as a boolean or clears it if null value given.
|
protected <T> Config<S> |
setOrClear(String name,
Collection<T> collection)
Sets the specified property as an array of items in a given collection or
clears it if null is given.
|
protected Config<S> |
setOrClear(String name,
Double value)
Sets the specified property as a double or clears it if null value given.
|
protected <E extends Enum> |
setOrClear(String name,
E value)
Sets the specified property as a double or clears it if null value given.
|
protected Config<S> |
setOrClear(String name,
Integer value)
Sets the specified property as an integer or clears it if null value given.
|
protected Config<S> |
setOrClear(String name,
Long value)
Sets the specified property as a long or clears it if null value given.
|
protected Config<S> |
setOrClear(String name,
String value)
Sets the specified property as a string or clears it if null value given.
|
S |
subject()
Returns the specific subject to which this configuration pertains.
|
protected S subject
protected String key
protected com.fasterxml.jackson.databind.JsonNode node
protected com.fasterxml.jackson.databind.node.ObjectNode object
protected com.fasterxml.jackson.databind.node.ArrayNode array
protected com.fasterxml.jackson.databind.ObjectMapper mapper
protected ConfigApplyDelegate delegate
public void init(S subject, String key, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectMapper mapper, ConfigApplyDelegate delegate)
subject - configuration subjectkey - configuration keynode - JSON node where configuration data is storedmapper - JSON object mapperdelegate - delegate contextpublic S subject()
public String key()
public com.fasterxml.jackson.databind.JsonNode node()
public void apply()
protected String get(String name, String defaultValue)
name - property namedefaultValue - default value if property not setprotected Config<S> setOrClear(String name, String value)
name - property namevalue - new value or null to clear the propertyprotected boolean get(String name, boolean defaultValue)
name - property namedefaultValue - default value if property not setprotected Config<S> setOrClear(String name, Boolean value)
name - property namevalue - new value or null to clear the propertyprotected int get(String name, int defaultValue)
name - property namedefaultValue - default value if property not setprotected Config<S> setOrClear(String name, Integer value)
name - property namevalue - new value or null to clear the propertyprotected long get(String name, long defaultValue)
name - property namedefaultValue - default value if property not setprotected Config<S> setOrClear(String name, Long value)
name - property namevalue - new value or null to clear the propertyprotected double get(String name, double defaultValue)
name - property namedefaultValue - default value if property not setprotected Config<S> setOrClear(String name, Double value)
name - property namevalue - new value or null to clear the propertyprotected <E extends Enum<E>> E get(String name, E defaultValue, Class<E> enumClass)
E - type of enumname - property namedefaultValue - default value if property not setenumClass - the enum classprotected <E extends Enum> Config<S> setOrClear(String name, E value)
E - type of enumname - property namevalue - new value or null to clear the propertyprotected <T> List<T> getList(String name, java.util.function.Function<String,T> function)
T - type of itemname - property namefunction - mapper from string to itemprotected <T> Config<S> setOrClear(String name, Collection<T> collection)
T - type of itemsname - propertyNamecollection - collection of itemsCopyright © 2015. All rights reserved.