Class DefaultApplicationSettings

java.lang.Object
eu.rarogsoftware.rarog.platform.core.settings.DefaultApplicationSettings
All Implemented Interfaces:
ApplicationSettings

@ExportComponent @Component public class DefaultApplicationSettings extends Object implements ApplicationSettings
Default implementation of ApplicationSettings.
  • Constructor Details

    • DefaultApplicationSettings

      public DefaultApplicationSettings(SettingsStore settingsStore)
  • Method Details

    • getSetting

      public <T> Optional<T> getSetting(String key, Class<T> type)
      Description copied from interface: ApplicationSettings
      Get setting value from default setting store. Returns empty if no value found
      Specified by:
      getSetting in interface ApplicationSettings
      Type Parameters:
      T - returned setting type
      Parameters:
      key - setting key
      type - returned type
      Returns:
      setting for key
    • getSettingAsString

      public Optional<String> getSettingAsString(String key)
      Description copied from interface: ApplicationSettings
      Get setting value from default setting store. Returns empty if no value found
      Specified by:
      getSettingAsString in interface ApplicationSettings
      Parameters:
      key - setting key
      Returns:
      setting for key
    • getSettingOrDefault

      public <T> T getSettingOrDefault(String key, Class<T> type)
      Description copied from interface: ApplicationSettings
      Get setting value from default setting store. Returns default value or null if no default value
      Specified by:
      getSettingOrDefault in interface ApplicationSettings
      Type Parameters:
      T - returned setting type
      Parameters:
      key - setting key
      type - returned type
      Returns:
      setting for key
    • isTrue

      public boolean isTrue(String key)
      Description copied from interface: ApplicationSettings
      Assumes that setting is boolean type and returns primitive boolean.
      Specified by:
      isTrue in interface ApplicationSettings
      Parameters:
      key - setting key
      Returns:
      true if setting is set to true or if default value is set to true, false otherwise
    • getSettingOrDefaultAsString

      public String getSettingOrDefaultAsString(String key)
      Description copied from interface: ApplicationSettings
      Get setting value from default setting store. Returns default value or null if no default value
      Specified by:
      getSettingOrDefaultAsString in interface ApplicationSettings
      Parameters:
      key - setting key
      Returns:
      setting for key
    • getPropertyBackedSetting

      public <T> T getPropertyBackedSetting(String key, Class<T> type)
      Description copied from interface: ApplicationSettings
      Get setting value from system properties or default setting store or default value.
      Specified by:
      getPropertyBackedSetting in interface ApplicationSettings
      Type Parameters:
      T - returned setting type
      Parameters:
      key - setting key
      type - returned type
      Returns:
      setting for key
    • getPropertyBackedSettingAsString

      public String getPropertyBackedSettingAsString(String key)
      Description copied from interface: ApplicationSettings
      Get setting value from system properties or default setting store or default value.
      Specified by:
      getPropertyBackedSettingAsString in interface ApplicationSettings
      Parameters:
      key - setting key
      Returns:
      setting for key
    • setSetting

      public <T> void setSetting(String key, T value)
      Description copied from interface: ApplicationSettings
      Persist setting value. If no serializer specified then tries store setting value as json
      Specified by:
      setSetting in interface ApplicationSettings
      Type Parameters:
      T - returned setting type
      Parameters:
      key - setting key
      value - value to persist
    • setDefaultSetting

      public <T> void setDefaultSetting(String key, T defaultValue)
      Description copied from interface: ApplicationSettings
      Configures default value for setting.
      Specified by:
      setDefaultSetting in interface ApplicationSettings
      Type Parameters:
      T - returned setting type
      Parameters:
      key - setting key
      defaultValue - value to persist
    • addTypeSerializer

      public <T> void addTypeSerializer(Class<T> type, SettingSerializer<T> serializer)
      Description copied from interface: ApplicationSettings
      Adds serializer for custom type. Replaces default json serializer for provided type
      Specified by:
      addTypeSerializer in interface ApplicationSettings
      Type Parameters:
      T - serializable type
      Parameters:
      type - type of serializer
      serializer - instance of serializer for provided type