public interface ConfigurationSection
Synchronized with the commit on 20-December-2021.
| Modifier and Type | Method and Description |
|---|---|
void |
addDefault(@NotNull String path,
@Nullable Object value)
Sets the default value in the root at the given path as provided.
|
boolean |
contains(@NotNull String path)
Checks if this configuration section contains the given path.
|
boolean |
contains(@NotNull String path,
boolean ignoreDefault)
Checks if this configuration section contains the given path.
|
@NotNull ConfigurationSection |
createSection(@NotNull String path)
Creates an empty configuration section at the given path.
|
@NotNull ConfigurationSection |
createSection(@NotNull String path,
@NotNull Map<?,?> entries)
Creates a configuration section at the given path, with the given values.
|
@Nullable Object |
get(@NotNull String path)
Gets the value at the given path.
|
@Nullable Object |
get(@NotNull String path,
@Nullable Object def)
Gets the value at the given path, returning the given default value if
one has not been set.
|
boolean |
getBoolean(@NotNull String path)
Gets the boolean value at the given path.
|
boolean |
getBoolean(@NotNull String path,
boolean def)
Gets the boolean value at the given path.
|
@NotNull List<Boolean> |
getBooleanList(@NotNull String path)
Gets the list of booleans at the given path.
|
byte |
getByte(@NotNull String path)
Gets the byte value at the given path.
|
byte |
getByte(@NotNull String path,
byte def)
Gets the byte value at the given path.
|
@NotNull List<Byte> |
getByteList(@NotNull String path)
Gets the list of bytes at the given path.
|
char |
getChar(@NotNull String path)
Gets the char value at the given path.
|
char |
getChar(@NotNull String path,
char def)
Gets the char value at the given path.
|
@NotNull List<Character> |
getCharList(@NotNull String path)
Gets the list of chars at the given path.
|
@NotNull @UnmodifiableView List<String> |
getComments(@NotNull String path)
Gets the comments by path.
|
@Nullable ConfigurationSection |
getConfigurationSection(@NotNull String path)
Gets the configuration section value at the given path.
|
@Nullable String |
getCurrentPath()
Gets the path of this configuration section from its root configuration.
|
@Nullable ConfigurationSection |
getDefaultSection()
Gets the equivalent configuration section from the default configuration
defined in
getRoot(). |
double |
getDouble(@NotNull String path)
Gets the double value at the given path.
|
double |
getDouble(@NotNull String path,
double def)
Gets the double value at the given path.
|
@NotNull List<Double> |
getDoubleList(@NotNull String path)
Gets the list of doubles at the given path.
|
float |
getFloat(@NotNull String path)
Gets the float value at the given path.
|
float |
getFloat(@NotNull String path,
float def)
Gets the float value at the given path.
|
@NotNull List<Float> |
getFloatList(@NotNull String path)
Gets the list of floats at the given path.
|
@NotNull @UnmodifiableView List<String> |
getInlineComments(@NotNull String path)
Gets the inline comments by path.
|
int |
getInt(@NotNull String path)
Gets the int value at the given path.
|
int |
getInt(@NotNull String path,
int def)
Gets the int value at the given path.
|
@NotNull List<Integer> |
getIntList(@NotNull String path)
Gets the list of ints at the given path.
|
@NotNull @UnmodifiableView Set<String> |
getKeys(boolean deep)
Gets a set containing a copy of all keys in this configuration section.
|
@Nullable List<?> |
getList(@NotNull String path)
Gets the list value at the given path.
|
@Nullable List<?> |
getList(@NotNull String path,
@Nullable List<?> def)
Gets the list value at the given path.
|
long |
getLong(@NotNull String path)
Gets the long value at the given path.
|
long |
getLong(@NotNull String path,
long def)
Gets the long value at the given path.
|
@NotNull List<Long> |
getLongList(@NotNull String path)
Gets the list of longs at the given path.
|
@NotNull List<Map<?,?>> |
getMapList(@NotNull String path)
Gets the list of maps at the given path.
|
@NotNull String |
getName()
Gets the name of this individual configuration section in its path.
|
<T> T |
getObject(@NotNull String path,
@NotNull Class<T> clazz)
Gets the value of type
T at the given path. |
<T> T |
getObject(@NotNull String path,
@NotNull Class<T> clazz,
T def)
Gets the value of type
T at the given path. |
@Nullable ConfigurationSection |
getParent()
Gets the parent configuration section that directly contains this
section.
|
@Nullable Configuration |
getRoot()
Gets the root configuration that contains this configuration section.
|
<T extends ConfigurationSerializable> |
getSerializable(@NotNull String path,
@NotNull Class<T> clazz)
Gets the configuration serializable value of type
T at the given
path. |
<T extends ConfigurationSerializable> |
getSerializable(@NotNull String path,
@NotNull Class<T> clazz,
T def)
Gets the configuration serializable value of type
T value at the
given path. |
short |
getShort(@NotNull String path)
Gets the short value at the given path.
|
short |
getShort(@NotNull String path,
short def)
Gets the short value at the given path.
|
@NotNull List<Short> |
getShortList(@NotNull String path)
Gets the list of shorts at the given path.
|
@Nullable String |
getString(@NotNull String path)
Gets the string value at the given path.
|
@Nullable String |
getString(@NotNull String path,
@Nullable String def)
Gets the string value at the given path.
|
@NotNull List<String> |
getStringList(@NotNull String path)
Gets the list of strings at the given path.
|
@NotNull @UnmodifiableView Map<String,Object> |
getValues(boolean deep)
Gets a map containing a copy of all keys and their respective values for
this configuration section.
|
boolean |
isBoolean(@NotNull String path)
Checks if the value at the given path is a boolean.
|
boolean |
isByte(@NotNull String path)
Checks if the value at the given path is a byte.
|
boolean |
isChar(@NotNull String path)
Checks if the value at the given path is a char.
|
boolean |
isConfigurationSection(@NotNull String path)
Checks if the value at the given path is a configuration section.
|
boolean |
isDouble(@NotNull String path)
Checks if the value at the given path is a double.
|
boolean |
isFloat(@NotNull String path)
Checks if the value at the given path is a float.
|
boolean |
isInt(@NotNull String path)
Checks if the value at the given path is an int.
|
boolean |
isList(@NotNull String path)
Checks if the value at the given path is a generic list.
|
boolean |
isLong(@NotNull String path)
Checks if the value at the given path is a long.
|
boolean |
isNumber(@NotNull String path)
Checks if the value at the given path is a number.
|
boolean |
isSet(@NotNull String path)
Checks if this configuration section has a value set for the given path.
|
boolean |
isShort(@NotNull String path)
Checks if the value at the given path is a short.
|
boolean |
isString(@NotNull String path)
Checks if the value at the given path is a string.
|
void |
set(@NotNull String path,
@Nullable Object value)
Sets the given path to the given value.
|
void |
setComments(@NotNull String path,
@Nullable List<String> comments)
Sets the comments at the given path.
|
void |
setInlineComments(@NotNull String path,
@Nullable List<String> inLineComments)
Sets the inline comments at the given path.
|
@NotNull @NotNull @UnmodifiableView Set<String> getKeys(boolean deep)
If deep is set to true, then the set will contain all
keys within this configuration section as well as the keys of any
children sections of this section, working recursively down through each
child's potential children. As a result, all the keys will be the
fully-qualified paths.
If deep is set to false, then the set will contain only
the keys of any values of this configuration section, even if those
values themselves are children configuration sections.
In either case, the set will be unmodifiable, and any updates to the keys of this configuration section will not be reflected in the returned set.
deep - true if the set is to contain the keys of the
children configuration section(s) of this section
(recursive), false otherwise.@NotNull @NotNull @UnmodifiableView Map<String,Object> getValues(boolean deep)
If deep is set to true, then the map will contain all
key-value pairings within this configuration section, as well as the
key-value pairings of any children sections of this section, working
recursively down through each child's potential children. As a result,
all the keys will be the fully-qualified paths.
If deep is set to false, then the map will contain only
the key-value pairings of this configuration section, even if those
values themselves are children configuration sections.
In either case, the map will be unmodifiable, and any updates to the keys, values, or the pairings of this configuration section will not be reflected in the returned set.
deep - true if the map is to contain the key-value pairings
of the children configuration section(s) of this section
(recursive), false otherwise.@Nullable @Nullable String getCurrentPath()
If this configuration section is a configuration itself, this will return an empty string.
If this configuration section is no longer contained within a root
configuration for any reason, such as being replaced with a different
value, this may return null.
This will return the fully-qualified path of this section. If only the
final part of the path of this section is desired, please use
getName().
null if this section is
orphaned.@NotNull @NotNull String getName()
This will always be the final part of
getCurrentPath(), unless this configuration
section is orphaned.
@Nullable @Nullable Configuration getRoot()
If this configuration section is itself a configuration, this will return this section.
If this configuration section is no longer contained within a root
configuration for any reason, such as being replaced with a different
value, this may return null.
null if this section is orphaned.@Nullable @Nullable ConfigurationSection getParent()
If this configuration section is itself a configuration, this will return
null.
If this configuration section is no longer contained within a root
configuration for any reason, such as being replaced with a different
value, this may return null.
null if this section does not have a parent.@Nullable @Nullable ConfigurationSection getDefaultSection()
getRoot().
If the root configuration contains no defaults, or the defaults do not
contain a value for this configuration section's path, or the value at
this path is not itself a configuration section, this will return
null.
null if one does not exist or is not
the correct type.void addDefault(@NotNull
@NotNull String path,
@Nullable
@Nullable Object value)
If no source configuration was provided as a default collection, then a new memory configuration will be created to hold the given default value.
If value is null, the value will be removed from the default
configuration source.
If the value as returned by
getDefaultSection() is null, then
this will create a new configuration section at the path, replacing
anything that may have existed there previously.
path - The path of the default value to set.value - The value to set the default to.@NotNull @NotNull @UnmodifiableView List<String> getComments(@NotNull @NotNull String path)
If no comments exist, and empty list will be returned. A null
entry represents an empty line and an empty string represents an empty
comment line (# with nothing after it).
The returned list will be unmodifiable, and any changes to the underlying comments in this configuration section will not be reflected in the returned list.
path - The path of the comments to get.@NotNull @NotNull @UnmodifiableView List<String> getInlineComments(@NotNull @NotNull String path)
If no comments exist, an empty list will be returned. A null
entry represents an empty line and an empty string represents an empty
comment line (# with nothing after it).
The returned list will be unmodifiable, and any changes to the underlying inline comments in this configuration section will not be reflected in the returned list.
path - The path of the comments to get.void setComments(@NotNull
@NotNull String path,
@Nullable
@Nullable List<String> comments)
If the given list is null itself, any existing comments will be
removed. Otherwise, the existing comments will be replaced with the
contents of the given list, regardless of the previous comment values.
A null entry in the list will result in an empty line, and an
empty string as an entry will result in an empty comment line (#
with nothing after it).
path - The path of the comments to set.comments - The new comments to set at the given path, where every
entry in the list represents one line. null to
remove any existing comments.void setInlineComments(@NotNull
@NotNull String path,
@Nullable
@Nullable List<String> inLineComments)
If the given list is null itself, any existing inline comments
will be removed. Otherwise, the existing inline comments will be replaced
with the contents of the given list, regardless of the previous comment
values.
A null entry in the list will result in an empty line, and an
empty string as an entry will result in an empty comment line (#
with nothing after it).
path - The path of the inline comments to set.inLineComments - The new inline comments to set at the given path,
where every entry in the list represents one line.
null to remove any existing inline
comments.@NotNull @NotNull ConfigurationSection createSection(@NotNull @NotNull String path)
Any value that was previously set at this path will be overwritten. If the previous value was a configuration section itself, that section will be orphaned.
path - The path to create the configuration section at.@NotNull @NotNull ConfigurationSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?,?> entries)
Any value that was previously set at this path will be overwritten. If the previous value was a configuration section itself, that section will be orphaned.
path - The path to create the configuration section at.entries - The key-value pairings to place in the newly-created
configuration section.boolean isSet(@NotNull
@NotNull String path)
If the value for the given path does not exist but a default value has
been set, this will still return false. If the status of a
default value is desired, please use
contains(String).
path - The path to check for existence.true if this configuration section contains the given
path, regardless of having a default, false otherwise.contains(String)void set(@NotNull
@NotNull String path,
@Nullable
@Nullable Object value)
If the given value is null, the entry will be removed.
The given value may not be a configuration or a configuration section. If
a new configuration section is desired, please use
createSection(String).
path - The path to the given value.value - The new value to store at the given path.boolean contains(@NotNull
@NotNull String path)
If the value for the given path does not exist but a default value has
been set, this will return true. If the existence of a default
value is to be ignored, please use
contains(String, boolean), where
ignoreDefault is true.
path - The path to check for existence.true if this configuration section contains the given
path, either via an actual value or default value being set,
false otherwise.contains(String, boolean)boolean contains(@NotNull
@NotNull String path,
boolean ignoreDefault)
If true is given for ignoreDefault, then this will
return true only if a value has been set for the given path.
If false is given for ignoreDefaults, then this will
return true if a value has been set for the given path, or if a
default value has been set for the given path.
path - The path to check for existence.ignoreDefault - true if any default values should be ignored
when checking for a value at the path, false
otherwise.true if this configuration section contains an actual
value at the given path, or if a default value has been set
and ignoreDefault is false, false
otherwise.@Nullable @Nullable Object get(@NotNull @NotNull String path)
If a value has not been set at the given path, but a default value has
been set, this will return the default value. If no value and no default
value have been set, this will return null.
path - The path of the value to retrieve.@Contract(value="_, !null -> !null") @Nullable @Nullable Object get(@NotNull @NotNull String path, @Nullable @Nullable Object def)
If a value has not been set at the given path, the given default value will be returned, regardless of whether a default value exists in the root configuration.
path - The path of the value to retrieve.def - The value to use as a default.boolean isBoolean(@NotNull
@NotNull String path)
If the value exists at the given path but is not a boolean, this will
return false.
If the value does not exist at the given path but a default value has been set, this will check the default value and return appropriately.
path - The path of the boolean to check.true if a boolean value exists, or if there is no value,
a default has been set, and it is a boolean, false
otherwise.boolean getBoolean(@NotNull
@NotNull String path)
If the value exists at the given path but is not a boolean, this will
return false.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the boolean to retrieve.boolean getBoolean(@NotNull
@NotNull String path,
boolean def)
If the value exists at the given path but is not a boolean, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the boolean to retrieve.def - The boolean to use as the default.boolean isNumber(@NotNull
@NotNull String path)
If the value exists at the given path but is not a number, this will
return false.
If the value does not exist at the give path but a default value has been set, this will check that value and return appropriately.
This method is meant to be a more generic check than the specific
number-based checks below, such as
isByte(String), or
isDouble(String). Those methods check
to see if the requested value (or default) is of the exact type, whereas
this method will simply check for a number.
path - The path of the number to check.true if a number value exists, or if there is no value,
a default has been set, and it is a number, false
otherwise.isByte(String),
isShort(String),
isInt(String),
isLong(String),
isFloat(String),
isDouble(String)boolean isByte(@NotNull
@NotNull String path)
If the value exists at the given path but is not a byte, this will
return false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically a byte. If the value is another type of number, this will
return false. To check for a generic number please use
isNumber(String).
path - The path of the byte to check.true if a byte value exists, or if there is no value, a
default has been set, and it is a byte, false otherwise.isNumber(String)byte getByte(@NotNull
@NotNull String path)
If the value exists at the given path but is not a byte, this will return
(byte) 0.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the byte to retrieve.byte getByte(@NotNull
@NotNull String path,
byte def)
If the value exists at the given path but is not a byte, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the byte to retrieve.def - The byte to use as the default.boolean isShort(@NotNull
@NotNull String path)
If the value exists at the given path but is not a short, this will
return false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically a short. If the value is another type of number, this will
return false. To check for a generic number, please use
isNumber(String).
path - The path of the short to check.true if a short value exists, or if there is no value, a
default has been set, and it is a short, false otherwise.isNumber(String)short getShort(@NotNull
@NotNull String path)
If the value exists at the given path but is not a short, this will
return (short) 0.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the short to retrieve.short getShort(@NotNull
@NotNull String path,
short def)
If the value exists at the given path but is not a short, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the short to retrieve.def - The short to use as the default.boolean isInt(@NotNull
@NotNull String path)
If the value exists at the given path but is not an int, this will return
false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically an int. If the value is another type of number, this will
return false. To check for a generic number, please use
isNumber(String).
path - The path of the int to check.true if an int value exists, or if there is no value, a
default has been set, and it is an int, false otherwise.isNumber(String)int getInt(@NotNull
@NotNull String path)
If the value exists at the given path but is not an int, this will return
0.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the int to retrieve.int getInt(@NotNull
@NotNull String path,
int def)
If the value exists at the given path but is not an int, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root Configuration, it
will be ignored, even if the given path does not have a set value.
path - The path of the int to retrieve.def - The int to use as the default.boolean isLong(@NotNull
@NotNull String path)
If the value exists at the given path but is not a long, this will return
false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically a long. If the value is another type of number, this will
return false. To check for a generic number, please use
isNumber(String).
path - The path of the long to check.true if a long value exists, or if there is no value, a
default has been set, and it is a long, false otherwise.isNumber(String)long getLong(@NotNull
@NotNull String path)
If the value exists at the given path but is not a long, this will return
0L.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the long to retrieve.long getLong(@NotNull
@NotNull String path,
long def)
If the value exists at the given path but is not a long, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the long to retrieve.def - The long to use as the default.boolean isFloat(@NotNull
@NotNull String path)
If the value exists at the given path but is not a float, this will
return false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically a float. If the value is another type of number, this will
return false. To check for a generic number, please use
isNumber(String).
path - The path of the float to check.true if a float value exists, or if there is no value, a
default has been set, and it is a float, false otherwise.isNumber(String)float getFloat(@NotNull
@NotNull String path)
If the value exists at the given path but is not a float, this will
return 0.0F.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the float to retrieve.float getFloat(@NotNull
@NotNull String path,
float def)
If the value exists at the given path but is not a float, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the float to retrieve.def - The float to use as the default.boolean isDouble(@NotNull
@NotNull String path)
If the value exists at the given path but is not a double, this will
return false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
This method will check to see if the requested value (or default) is
specifically a double. If the value is another type of number, this will
return false. To check for a generic number, please use
isNumber(String).
path - The path of the double to check.true if a double value exists, or if there is no value, a
default has been set, and it is a double, false
otherwise.isNumber(String)double getDouble(@NotNull
@NotNull String path)
If the value exists at the given path but is not a double, this will
return 0.0D.
If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.
path - The path of the double to retrieve.double getDouble(@NotNull
@NotNull String path,
double def)
If the value exists at the given path but is not a double, or if the value does not exist at the given path, this will return the given default.
If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.
path - The path of the double to retrieve.def - The double to use as the default.boolean isChar(@NotNull
@NotNull String path)
If the value exists at the given path but is not a char, this will return
false.
If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.
path - The path of the char to check.true if a char value exists, or if there is no value, a
default has been set, and it is a char, false otherwise.char getChar(@NotNull
@NotNull String path)
If the value exists at the given path but is not a char, this will return