Interface SettingDao

All Superinterfaces:
BatchableDao<Setting>

public interface SettingDao extends 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
  • Field Details

    • EVENT_TOPIC_SETTING_CHANGED

      static final String 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 various SETTING_* properties will be provided as event properties.
      See Also:
    • SETTING_KEY

      static final String SETTING_KEY
      Event property key for the setting key.
      See Also:
    • SETTING_TYPE

      static final String SETTING_TYPE
      Event property key for the setting type.
      See Also:
    • SETTING_VALUE

      static final String SETTING_VALUE
      Event property key for the setting value.
      See Also:
  • Method Details

    • storeSetting

      void storeSetting(String key, String value)
      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 key
      value - the setting value
    • storeSetting

      void storeSetting(String key, String type, String value)
      Persist a new key+type/value pair, or update an existing key+type.
      Parameters:
      key - the setting key
      type - the type key
      value - the setting value
    • storeSetting

      void storeSetting(Setting setting)
      Persist a Setting, or update an existing Setting.
      Parameters:
      setting - the setting
    • readSetting

      Setting readSetting(String key, String type)
      Get a Setting object for a given setting key+type.
      Parameters:
      key - the key
      type - the type
      Returns:
      the setting, or null if not found
    • getSetting

      String getSetting(String key)
      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

      List<net.solarnetwork.domain.KeyValuePair> getSettingValues(String key)
      Get all settings for a specific key.
      Parameters:
      key - the key to get the settings for
      Returns:
      list of KeyValuePair objects, where the key will be set to the type value
      Since:
      1.3
    • getSetting

      String getSetting(String key, String type)
      Get the value for a key+type.
      Parameters:
      key - the key to get the value for
      type - the type to get the value for
      Returns:
      the associated value, or null if key not found
    • deleteSetting

      boolean deleteSetting(String key)
      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

      boolean deleteSetting(String key, String type)
      Delete a setting key+type/value pair.

      This method will not fail if the key does not exist.

      Parameters:
      key - the key to delete
      type - the type to delete
      Returns:
      true if the key existed and was deleted
    • getSettingModificationDate

      Date getSettingModificationDate(String key, String type)
      Get the modification date for a specific setting.
      Parameters:
      key - the key
      type - the type
      Returns:
      the date
    • getMostRecentModificationDate

      Date getMostRecentModificationDate()
      Get the most recent modification date of all settings.

      The special type value Setting.SettingFlag.IgnoreModificationDate is considered by this method, and rows with this type are ignored when calculating the most recent modification date.

      Returns:
      the modification date