Class Settings

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static Settings.Builder builder()
      Returns a builder to be used in order to build settings.
      boolean equals​(java.lang.Object o)  
      Settings filter​(java.util.function.Predicate<java.lang.String> predicate)
      Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate.
      static Settings fromXContent​(XContentParser parser)
      Parsers the generated xcontent from toXContent(XContentBuilder, Params) into a new Settings object.
      java.lang.String get​(java.lang.String setting)
      Returns the setting value associated with the setting key.
      java.lang.String get​(java.lang.String setting, java.lang.String defaultValue)
      Returns the setting value associated with the setting key.
      java.lang.Boolean getAsBoolean​(java.lang.String setting, java.lang.Boolean defaultValue)
      Returns the setting value (as boolean) associated with the setting key.
      java.lang.Boolean getAsBooleanLenientForPreEs6Indices​(Version indexVersion, java.lang.String setting, java.lang.Boolean defaultValue, DeprecationLogger deprecationLogger)
      Deprecated.
      Only used to provide automatic upgrades for pre 6.0 indices.
      ByteSizeValue getAsBytesSize​(java.lang.String setting, ByteSizeValue defaultValue)
      Returns the setting value (as size) associated with the setting key.
      java.lang.Double getAsDouble​(java.lang.String setting, java.lang.Double defaultValue)
      Returns the setting value (as double) associated with the setting key.
      java.lang.Float getAsFloat​(java.lang.String setting, java.lang.Float defaultValue)
      Returns the setting value (as float) associated with the setting key.
      java.util.Map<java.lang.String,​Settings> getAsGroups()
      Returns group settings for the given setting prefix.
      java.util.Map<java.lang.String,​Settings> getAsGroups​(boolean ignoreNonGrouped)  
      java.lang.Integer getAsInt​(java.lang.String setting, java.lang.Integer defaultValue)
      Returns the setting value (as int) associated with the setting key.
      java.util.List<java.lang.String> getAsList​(java.lang.String key)
      The values associated with a setting key as an immutable list.
      java.util.List<java.lang.String> getAsList​(java.lang.String key, java.util.List<java.lang.String> defaultValue)
      The values associated with a setting key as an immutable list.
      java.util.List<java.lang.String> getAsList​(java.lang.String key, java.util.List<java.lang.String> defaultValue, java.lang.Boolean commaDelimited)
      The values associated with a setting key as an immutable list.
      java.lang.Long getAsLong​(java.lang.String setting, java.lang.Long defaultValue)
      Returns the setting value (as long) associated with the setting key.
      ByteSizeValue getAsMemory​(java.lang.String setting, java.lang.String defaultValue)
      Returns the setting value (as size) associated with the setting key.
      RatioValue getAsRatio​(java.lang.String setting, java.lang.String defaultValue)
      Returns the setting value (as a RatioValue) associated with the setting key.
      Settings getAsSettings​(java.lang.String setting)
      Returns the settings mapped to the given setting name.
      SizeValue getAsSize​(java.lang.String setting, SizeValue defaultValue)
      Returns the setting value (as size) associated with the setting key.
      TimeValue getAsTime​(java.lang.String setting, TimeValue defaultValue)
      Returns the setting value (as time) associated with the setting key.
      Version getAsVersion​(java.lang.String setting, Version defaultVersion)
      Returns a parsed version.
      Settings getByPrefix​(java.lang.String prefix)
      A settings that are filtered (and key is removed) with the specified prefix.
      java.util.Map<java.lang.String,​Settings> getGroups​(java.lang.String settingPrefix)
      Returns group settings for the given setting prefix.
      java.util.Map<java.lang.String,​Settings> getGroups​(java.lang.String settingPrefix, boolean ignoreNonGrouped)
      Returns group settings for the given setting prefix.
      int hashCode()  
      boolean hasValue​(java.lang.String key)
      Returns true iff the given key has a value in this settings object
      boolean isEmpty()
      Returns true if this settings object contains no settings
      java.util.Set<java.lang.String> keySet()
      Returns the fully qualified setting names contained in this settings object.
      java.util.Set<java.lang.String> names()  
      static Settings readSettingsFromStream​(StreamInput in)  
      int size()
      Returns the number of settings in this settings object.
      java.lang.String toDelimitedString​(char delimiter)
      Returns the settings as delimited string.
      java.lang.String toString()  
      XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params)  
      static void writeSettingsToStream​(Settings settings, StreamOutput out)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final Settings EMPTY
      • FORMAT_PARAMS

        public static final java.util.Set<java.lang.String> FORMAT_PARAMS
    • Method Detail

      • getByPrefix

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

        public Settings filter​(java.util.function.Predicate<java.lang.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​(java.lang.String setting)
        Returns the settings mapped to the given setting name.
      • get

        public java.lang.String get​(java.lang.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 java.lang.String get​(java.lang.String setting,
                                    java.lang.String defaultValue)
        Returns the setting value associated with the setting key. If it does not exists, returns the default value provided.
      • getAsFloat

        public java.lang.Float getAsFloat​(java.lang.String setting,
                                          java.lang.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 java.lang.Double getAsDouble​(java.lang.String setting,
                                            java.lang.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 java.lang.Integer getAsInt​(java.lang.String setting,
                                          java.lang.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 java.lang.Long getAsLong​(java.lang.String setting,
                                        java.lang.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​(java.lang.String key)
        Returns true iff the given key has a value in this settings object
      • getAsBoolean

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

        @Deprecated
        public java.lang.Boolean getAsBooleanLenientForPreEs6Indices​(Version indexVersion,
                                                                     java.lang.String setting,
                                                                     java.lang.Boolean defaultValue,
                                                                     DeprecationLogger deprecationLogger)
        Deprecated.
        Only used to provide automatic upgrades for pre 6.0 indices.
        Returns the setting value (as boolean) associated with the setting key. If it does not exist, returns the default value provided. If the index was created on Elasticsearch below 6.0, booleans will be parsed leniently otherwise they are parsed strictly. See Booleans.isBooleanLenient(char[], int, int) for the definition of a "lenient boolean" and Booleans.isBoolean(char[], int, int) for the definition of a "strict boolean".
      • getAsTime

        public TimeValue getAsTime​(java.lang.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​(java.lang.String setting,
                                         java.lang.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
      • getAsRatio

        public RatioValue getAsRatio​(java.lang.String setting,
                                     java.lang.String defaultValue)
                              throws SettingsException
        Returns the setting value (as a RatioValue) associated with the setting key. Provided values can either be a percentage value (eg. 23%), or expressed as a floating point number (eg. 0.23). If it does not exist, parses the default value provided.
        Throws:
        SettingsException
      • getAsSize

        public SizeValue getAsSize​(java.lang.String setting,
                                   SizeValue defaultValue)
                            throws SettingsException
        Returns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.
        Throws:
        SettingsException
      • getAsList

        public java.util.List<java.lang.String> getAsList​(java.lang.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 java.util.List<java.lang.String> getAsList​(java.lang.String key,
                                                          java.util.List<java.lang.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 java.util.List<java.lang.String> getAsList​(java.lang.String key,
                                                          java.util.List<java.lang.String> defaultValue,
                                                          java.lang.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
      • getGroups

        public java.util.Map<java.lang.String,​Settings> getGroups​(java.lang.String settingPrefix)
                                                                 throws SettingsException
        Returns group settings for the given setting prefix.
        Throws:
        SettingsException
      • getGroups

        public java.util.Map<java.lang.String,​Settings> getGroups​(java.lang.String settingPrefix,
                                                                        boolean ignoreNonGrouped)
                                                                 throws SettingsException
        Returns group settings for the given setting prefix.
        Throws:
        SettingsException
      • names

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

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • readSettingsFromStream

        public static Settings readSettingsFromStream​(StreamInput in)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSettingsToStream

        public static void writeSettingsToStream​(Settings settings,
                                                 StreamOutput out)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • 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 java.util.Set<java.lang.String> keySet()
        Returns the fully qualified setting names contained in this settings object.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object