Class Settings
java.lang.Object
org.elasticsearch.common.settings.Settings
- All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
public final class Settings
extends java.lang.Object
implements org.elasticsearch.common.xcontent.ToXContentFragment
An immutable settings implementation.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSettings.BuilderA builder allowing to put different settings and thenSettings.Builder.build()an immutable settings implementation. -
Field Summary
Fields Modifier and Type Field Description static SettingsEMPTYstatic java.util.Set<java.lang.String>FORMAT_PARAMS -
Method Summary
Modifier and Type Method Description static Settings.Builderbuilder()Returns a builder to be used in order to build settings.booleanequals(java.lang.Object o)Settingsfilter(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 SettingsfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)Parsers the generated xcontent fromtoXContent(XContentBuilder, Params)into a new Settings object.java.lang.Stringget(java.lang.String setting)Returns the setting value associated with the setting key.java.lang.Stringget(java.lang.String setting, java.lang.String defaultValue)Returns the setting value associated with the setting key.java.lang.BooleangetAsBoolean(java.lang.String setting, java.lang.Boolean defaultValue)Returns the setting value (as boolean) associated with the setting key.ByteSizeValuegetAsBytesSize(java.lang.String setting, ByteSizeValue defaultValue)Returns the setting value (as size) associated with the setting key.java.lang.DoublegetAsDouble(java.lang.String setting, java.lang.Double defaultValue)Returns the setting value (as double) associated with the setting key.java.lang.FloatgetAsFloat(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.lang.IntegergetAsInt(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.LonggetAsLong(java.lang.String setting, java.lang.Long defaultValue)Returns the setting value (as long) associated with the setting key.ByteSizeValuegetAsMemory(java.lang.String setting, java.lang.String defaultValue)Returns the setting value (as size) associated with the setting key.SettingsgetAsSettings(java.lang.String setting)Returns the settings mapped to the given setting name.org.elasticsearch.common.unit.TimeValuegetAsTime(java.lang.String setting, org.elasticsearch.common.unit.TimeValue defaultValue)Returns the setting value (as time) associated with the setting key.VersiongetAsVersion(java.lang.String setting, Version defaultVersion)Returns a parsed version.SettingsgetByPrefix(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.inthashCode()booleanhasValue(java.lang.String key)Returnstrueiff the given key has a value in this settings objectbooleanisEmpty()Returnstrueif this settings object contains no settingsjava.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 SettingsreadSettingsFromStream(StreamInput in)intsize()Returns the number of settings in this settings object.java.lang.StringtoDelimitedString(char delimiter)Returns the settings as delimited string.java.lang.StringtoString()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)static voidwriteSettingsToStream(Settings settings, StreamOutput out)
-
Field Details
-
EMPTY
-
FORMAT_PARAMS
public static final java.util.Set<java.lang.String> FORMAT_PARAMS
-
-
Method Details
-
getByPrefix
A settings that are filtered (and key is removed) with the specified prefix. -
filter
Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate. -
getAsSettings
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,
nullif 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)Returnstrueiff 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. -
getAsTime
public org.elasticsearch.common.unit.TimeValue getAsTime(java.lang.String setting, org.elasticsearch.common.unit.TimeValue defaultValue)Returns the setting value (as time) associated with the setting key. If it does not exists, returns the default value provided. -
getAsBytesSize
public ByteSizeValue getAsBytesSize(java.lang.String setting, ByteSizeValue defaultValue) throws SettingsExceptionReturns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.- Throws:
SettingsException
-
getAsMemory
public ByteSizeValue getAsMemory(java.lang.String setting, java.lang.String defaultValue) throws SettingsExceptionReturns 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
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 SettingsExceptionThe 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 SettingsExceptionThe 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 bydefaultValue- The default value to use if no value is specifiedcommaDelimited- 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 SettingsExceptionReturns 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 SettingsExceptionReturns group settings for the given setting prefix.- Throws:
SettingsException
-
getAsGroups
Returns group settings for the given setting prefix.- Throws:
SettingsException
-
getAsVersion
public Version getAsVersion(java.lang.String setting, Version defaultVersion) throws SettingsExceptionReturns a parsed version.- 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
readSettingsFromStream
- Throws:
java.io.IOException
-
writeSettingsToStream
public static void writeSettingsToStream(Settings settings, StreamOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
builder
Returns a builder to be used in order to build settings. -
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
fromXContent
public static Settings fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOExceptionParsers the generated xcontent fromtoXContent(XContentBuilder, Params)into a new Settings object. Note this method requires the parser to either be positioned on a null token or onXContentParser.Token.START_OBJECT.- Throws:
java.io.IOException
-
isEmpty
public boolean isEmpty()Returnstrueif this settings object contains no settings- Returns:
trueif 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:
toStringin classjava.lang.Object
-