Class Settings

    • Field Detail

      • EMPTY

        public static final Settings EMPTY
      • FORMAT_PARAMS

        public static final Set<String> FORMAT_PARAMS
    • Method Detail

      • getByPrefix

        public Settings getByPrefix​(String prefix)
        A settings that are filtered (and key is removed) with the specified prefix.
      • filter

        public Settings filter​(Predicate<String> predicate)
        Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate.
      • getAsSettings

        public Settings getAsSettings​(String setting)
        Returns the settings mapped to the given setting name.
      • get

        public String get​(String setting)
        Returns the setting value associated with the setting key.
        Parameters:
        setting - The setting key
        Returns:
        The setting value, null if it does not exists.
      • get

        public String get​(String setting,
                          String defaultValue)
        Returns the setting value associated with the setting key. If it does not exists, returns the default value provided.
      • getAsFloat

        public Float getAsFloat​(String setting,
                                Float defaultValue)
        Returns the setting value (as float) associated with the setting key. If it does not exists, returns the default value provided.
      • getAsDouble

        public Double getAsDouble​(String setting,
                                  Double defaultValue)
        Returns the setting value (as double) associated with the setting key. If it does not exists, returns the default value provided.
      • getAsInt

        public Integer getAsInt​(String setting,
                                Integer defaultValue)
        Returns the setting value (as int) associated with the setting key. If it does not exists, returns the default value provided.
      • getAsLong

        public Long getAsLong​(String setting,
                              Long defaultValue)
        Returns the setting value (as long) associated with the setting key. If it does not exists, returns the default value provided.
      • hasValue

        public boolean hasValue​(String key)
        Returns true iff the given key has a value in this settings object
      • getAsBoolean

        public Boolean getAsBoolean​(String setting,
                                    Boolean defaultValue)
        Returns the setting value (as boolean) associated with the setting key. If it does not exists, returns the default value provided.
      • getAsTime

        public TimeValue getAsTime​(String setting,
                                   TimeValue defaultValue)
        Returns the setting value (as time) associated with the setting key. If it does not exists, returns the default value provided.
      • getAsMemory

        public ByteSizeValue getAsMemory​(String setting,
                                         String defaultValue)
                                  throws SettingsException
        Returns the setting value (as size) associated with the setting key. Provided values can either be absolute values (interpreted as a number of bytes), byte sizes (eg. 1mb) or percentage of the heap size (eg. 12%). If it does not exists, parses the default value provided.
        Throws:
        SettingsException
      • getAsList

        public List<String> getAsList​(String key)
                               throws SettingsException
        The values associated with a setting key as an immutable list.

        It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.

        Parameters:
        key - The setting key to load the list by
        Returns:
        The setting list values
        Throws:
        SettingsException
      • getAsList

        public List<String> getAsList​(String key,
                                      List<String> defaultValue)
                               throws SettingsException
        The values associated with a setting key as an immutable list.

        If commaDelimited is true, it will automatically load a comma separated list under the settingPrefix and merge with the numbered format.

        Parameters:
        key - The setting key to load the list by
        Returns:
        The setting list values
        Throws:
        SettingsException
      • getAsList

        public List<String> getAsList​(String key,
                                      List<String> defaultValue,
                                      Boolean commaDelimited)
                               throws SettingsException
        The values associated with a setting key as an immutable list.

        It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.

        Parameters:
        key - The setting key to load the list by
        defaultValue - The default value to use if no value is specified
        commaDelimited - Whether to try to parse a string as a comma-delimited value
        Returns:
        The setting list values
        Throws:
        SettingsException
      • names

        public Set<String> names()
        Returns:
        The direct keys of this settings
      • toDelimitedString

        public String toDelimitedString​(char delimiter)
        Returns the settings as delimited string.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • builder

        public static Settings.Builder builder()
        Returns a builder to be used in order to build settings.
      • isEmpty

        public boolean isEmpty()
        Returns true if this settings object contains no settings
        Returns:
        true if this settings object contains no settings
      • size

        public int size()
        Returns the number of settings in this settings object.
      • keySet

        public Set<String> keySet()
        Returns the fully qualified setting names contained in this settings object.