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 class
Settings.Builder
A builder allowing to put different settings and thenSettings.Builder.build()
an immutable settings implementation.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
-
Field Summary
Fields Modifier and Type Field Description static Settings
EMPTY
static java.util.Set<java.lang.String>
FORMAT_PARAMS
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Method Summary
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(org.elasticsearch.common.xcontent.XContentParser parser)
Parsers the generated xcontent fromtoXContent(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.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.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.Settings
getAsSettings(java.lang.String setting)
Returns the settings mapped to the given setting name.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.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)
Returnstrue
iff the given key has a value in this settings objectboolean
isEmpty()
Returnstrue
if 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 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()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.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
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
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,
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)Returnstrue
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. -
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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in 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:
toXContent
in 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()Returnstrue
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 classjava.lang.Object
-