Class MemoryConfiguration
- All Implemented Interfaces:
Configuration
,ConfigurationSection
- Direct Known Subclasses:
FileConfiguration
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.-
Field Summary
Fields inherited from class com.plotsquared.core.configuration.MemorySection
map
-
Constructor Summary
ConstructorDescriptionCreates an emptyMemoryConfiguration
with no default values.MemoryConfiguration
(Configuration defaults) Creates an emptyMemoryConfiguration
using the specifiedConfiguration
as a source for all default values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Gets the sourceConfiguration
for this configuration.Gets the parentConfigurationSection
that directly contains thisConfigurationSection
.options()
Gets theConfigurationOptions
for thisConfiguration
.void
setDefaults
(Configuration defaults) Sets the source of all default values for thisConfiguration
.Methods inherited from class com.plotsquared.core.configuration.MemorySection
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, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isInt, isList, isLong, isPrimitiveWrapper, isSet, isString, mapChildrenKeys, mapChildrenValues, set, toDouble, toInt, toLong, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.plotsquared.core.configuration.ConfigurationSection
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, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isInt, isList, isLong, isSet, isString, set
-
Field Details
-
defaults
-
options
-
-
Constructor Details
-
MemoryConfiguration
public MemoryConfiguration()Creates an emptyMemoryConfiguration
with no default values. -
MemoryConfiguration
Creates an emptyMemoryConfiguration
using the specifiedConfiguration
as a source for all default values.- Parameters:
defaults
- Default value provider- Throws:
IllegalArgumentException
- Thrown if defaults is null
-
-
Method Details
-
addDefault
Description copied from interface:ConfigurationSection
Sets the default value in the root at the given path as provided.If no source
Configuration
was provided as a default collection, then a newMemoryConfiguration
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()
isnull
, then this will create a new section at the path, replacing anything that may have existed there previously.- Specified by:
addDefault
in interfaceConfiguration
- Specified by:
addDefault
in interfaceConfigurationSection
- Overrides:
addDefault
in classMemorySection
- Parameters:
path
- Path of the value to setvalue
- Value to set the default to
-
addDefaults
Description copied from interface:Configuration
Sets the default values of the given paths as provided.If no source
Configuration
was provided as a default collection, then a newMemoryConfiguration
will be created to hold the new default values.- Specified by:
addDefaults
in interfaceConfiguration
- Parameters:
defaults
- A map of Path->Values to add to defaults.
-
addDefaults
Description copied from interface:Configuration
Sets the default values of the given paths as provided.If no source
Configuration
was provided as a default collection, then a newMemoryConfiguration
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 check this, you should set the default source with
Configuration.setDefaults(Configuration)
.- Specified by:
addDefaults
in interfaceConfiguration
- Parameters:
defaults
- A configuration holding a list of defaults to copy.
-
getDefaults
Description copied from interface:Configuration
Gets the sourceConfiguration
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.- Specified by:
getDefaults
in interfaceConfiguration
- Returns:
- Configuration source for default values, or null if none exist.
-
setDefaults
Description copied from interface:Configuration
Sets the source of all default values for thisConfiguration
.If a previous source was set, or previous default values were defined, then they will not be copied to the new source.
- Specified by:
setDefaults
in interfaceConfiguration
- Parameters:
defaults
- New source of default values for this configuration.
-
getParent
Description copied from interface:ConfigurationSection
Gets the parentConfigurationSection
that directly contains thisConfigurationSection
.For any
Configuration
themselves, this will returnnull
.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
.- Specified by:
getParent
in interfaceConfigurationSection
- Overrides:
getParent
in classMemorySection
- Returns:
- Parent section containing this section.
-
options
Description copied from interface:Configuration
Gets theConfigurationOptions
for thisConfiguration
.All setters through this method are chainable.
- Specified by:
options
in interfaceConfiguration
- Returns:
- Options for this configuration
-