public class MemoryConfiguration extends MemorySection implements Configuration
Configuration
implementation that does not save or load
from any source, and stores all values in memory only.
This is useful for temporary Configurations for providing defaults.Modifier and Type | Field and Description |
---|---|
protected Configuration |
defaults |
protected MemoryConfigurationOptions |
options |
map
Constructor and Description |
---|
MemoryConfiguration()
Creates an empty
MemoryConfiguration with no default values. |
MemoryConfiguration(Configuration defaults)
Creates an empty
MemoryConfiguration using the specified
Configuration as a source for all default values. |
Modifier and Type | Method and Description |
---|---|
void |
addDefault(String path,
Object value)
Sets the default value in the root at the given path as provided.
|
void |
addDefaults(Configuration defaults)
Sets the default values of the given paths as provided.
|
void |
addDefaults(Map<String,Object> defaults)
Sets the default values of the given paths as provided.
|
Configuration |
getDefaults()
Gets the source
Configuration for this configuration. |
ConfigurationSection |
getParent()
Gets the parent
ConfigurationSection that directly contains
this ConfigurationSection . |
MemoryConfigurationOptions |
options()
Gets the
ConfigurationOptions for this Configuration . |
void |
setDefaults(Configuration defaults)
Sets the source of all default values for this
Configuration . |
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isEmpty, isInt, isList, isLong, isPrimitiveWrapper, isSet, isString, mapChildrenKeys, mapChildrenValues, set, size, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isEmpty, isInt, isList, isLong, isSet, isString, remove, set, size
protected Configuration defaults
protected MemoryConfigurationOptions options
public MemoryConfiguration()
MemoryConfiguration
with no default values.public MemoryConfiguration(Configuration defaults)
MemoryConfiguration
using the specified
Configuration
as a source for all default values.defaults
- Default value providerIllegalArgumentException
- Thrown if defaults is nullpublic void addDefaults(Map<String,Object> defaults)
Configuration
If no source Configuration
was provided as a default
collection, then a new MemoryConfiguration
will be created to
hold the new default values.
addDefaults
in interface Configuration
defaults
- A map of Path/Values to add to defaults.public void addDefaults(Configuration defaults)
Configuration
If no source Configuration
was provided as a default
collection, then a new MemoryConfiguration
will be created to
hold the new default value.
This method will not hold a reference to the specified Configuration,
nor will it automatically update if that Configuration ever changes. If
you require this, you should set the default source with Configuration.setDefaults(Configuration)
.
addDefaults
in interface Configuration
defaults
- A configuration holding a list of defaults to copy.public Configuration getDefaults()
Configuration
Configuration
for this configuration.
If no configuration source was set, but default values were added, then
a MemoryConfiguration
will be returned. If no source was set
and no defaults were set, then this method will return null.
getDefaults
in interface Configuration
public void setDefaults(Configuration defaults)
Configuration
Configuration
.
If a previous source was set, or previous default values were defined, then they will not be copied to the new source.
setDefaults
in interface Configuration
defaults
- New source of default values for this configuration.public MemoryConfigurationOptions options()
Configuration
ConfigurationOptions
for this Configuration
.
All setters through this method are chainable.
options
in interface Configuration
public ConfigurationSection getParent()
ConfigurationSection
ConfigurationSection
that directly contains
this ConfigurationSection
.
For any Configuration
themselves, this will return null.
If the section is no longer contained within its parent for any reason, such as being replaced with a different value, this may return null.
getParent
in interface ConfigurationSection
getParent
in class MemorySection
public void addDefault(String path, Object value)
ConfigurationSection
If no source Configuration
was provided as a default
collection, then a new MemoryConfiguration
will be created to
hold the new default value.
If value is null, the value will be removed from the default Configuration source.
If the value as returned by ConfigurationSection.getDefaultSection()
is null, then
this will create a new section at the path, replacing anything that may
have existed there previously.
addDefault
in interface Configuration
addDefault
in interface ConfigurationSection
addDefault
in class MemorySection
path
- Path of the value to set.value
- Value to set the default to.Copyright © 2023. All rights reserved.