Package net.solarnetwork.node.dao
Interface SettingDao
- All Superinterfaces:
BatchableDao<Setting>
Data access object API for setting key/value pairs.
This DAO is for very simple key/value based settings and other perstitable runtime data.
It also supports key+type/value pairs, where key and type are separate values. This can be useful for grouping sets of keys together, or for adding and namespace to prevent key collisions across different packages.
- Version:
- 1.3
- Author:
- matt
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.node.dao.BatchableDao
BatchableDao.BatchCallback<T>, BatchableDao.BatchCallbackResult, BatchableDao.BatchOptions, BatchableDao.BatchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEvent topic for when a non-volatile setting has been changed, by either adding new, updating an existing, or deleting.static final StringEvent property key for the setting key.static final StringEvent property key for the setting type.static final StringEvent property key for the setting value. -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteSetting(String key) Delete a setting key/value pair.booleandeleteSetting(String key, String type) Delete a setting key+type/value pair.Get the most recent modification date of all settings.getSetting(String key) Get the first value for a key.getSetting(String key, String type) Get the value for a key+type.getSettingModificationDate(String key, String type) Get the modification date for a specific setting.List<net.solarnetwork.domain.KeyValuePair> getSettingValues(String key) Get all settings for a specific key.readSetting(String key, String type) Get a Setting object for a given setting key+type.voidstoreSetting(String key, String value) Persist a new key/value pair, or update an existing key.voidstoreSetting(String key, String type, String value) Persist a new key+type/value pair, or update an existing key+type.voidstoreSetting(Setting setting) Persist a Setting, or update an existing Setting.Methods inherited from interface net.solarnetwork.node.dao.BatchableDao
batchProcess
-
Field Details
-
EVENT_TOPIC_SETTING_CHANGED
Event topic for when a non-volatile setting has been changed, by either adding new, updating an existing, or deleting. The variousSETTING_*properties will be provided as event properties.- See Also:
-
SETTING_KEY
Event property key for the setting key.- See Also:
-
SETTING_TYPE
Event property key for the setting type.- See Also:
-
SETTING_VALUE
Event property key for the setting value.- See Also:
-
-
Method Details
-
storeSetting
Persist a new key/value pair, or update an existing key.The type key will be set to a default value.
- Parameters:
key- the setting keyvalue- the setting value
-
storeSetting
Persist a new key+type/value pair, or update an existing key+type.- Parameters:
key- the setting keytype- the type keyvalue- the setting value
-
storeSetting
Persist a Setting, or update an existing Setting.- Parameters:
setting- the setting
-
readSetting
Get a Setting object for a given setting key+type.- Parameters:
key- the keytype- the type- Returns:
- the setting, or null if not found
-
getSetting
Get the first value for a key.- Parameters:
key- the key to get the first value for- Returns:
- the first associated value, or null if key not found
-
getSettingValues
Get all settings for a specific key.- Parameters:
key- the key to get the settings for- Returns:
- list of
KeyValuePairobjects, where thekeywill be set to thetypevalue - Since:
- 1.3
-
getSetting
Get the value for a key+type.- Parameters:
key- the key to get the value fortype- the type to get the value for- Returns:
- the associated value, or null if key not found
-
deleteSetting
Delete a setting key/value pair.This method will not fail if the key does not exist.
- Parameters:
key- the key to delete- Returns:
- true if the key existed and was deleted
-
deleteSetting
Delete a setting key+type/value pair.This method will not fail if the key does not exist.
- Parameters:
key- the key to deletetype- the type to delete- Returns:
- true if the key existed and was deleted
-
getSettingModificationDate
Get the modification date for a specific setting.- Parameters:
key- the keytype- the type- Returns:
- the date
-
getMostRecentModificationDate
Date getMostRecentModificationDate()Get the most recent modification date of all settings.The special
typevalueSetting.SettingFlag.IgnoreModificationDateis considered by this method, and rows with this type are ignored when calculating the most recent modification date.- Returns:
- the modification date
-