Class ConfigureSource<SECTION extends ConfigureSection,ORIGINAL,SELF extends ConfigureSource<SECTION,ORIGINAL,SELF>>
- Type Parameters:
SECTION
- The type of the root section.ORIGINAL
- The original configuration object.SELF
- The type of the source itself, for further implement support.
- All Implemented Interfaces:
ConfigureSection
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull ConfigurationHolder
<? extends SELF> protected long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ConfigureSource
(@NotNull ConfigurationHolder<? extends SELF> holder, long lastUpdateMillis) -
Method Summary
Modifier and TypeMethodDescriptionasMap()
Get this section as a map.@NotNull ConfigureSection
createSection
(@NotNull String path, @NotNull Map<?, ?> data) Creates a newConfigureSection
with specified values.@Nullable Object
Get the origin value of the path.getKeys
(boolean deep) Gets a set containing all keys in this section.long
getValues
(boolean deep) Gets a set containing all values in this section.@NotNull ConfigurationHolder
<? extends SELF> holder()
boolean
isExpired
(long parsedTime) protected abstract void
onReload()
Reload the configuration.abstract ORIGINAL
original()
@Nullable ConfigureSection
parent()
Source also represents the root section, so it has no parent@NotNull String
path()
Get the current section's path fromConfigureSection.parent()
of this section.char
Get the path separator for the section.void
reload()
void
Removes the value at the given path.abstract void
save()
Save the whole configuration.abstract SECTION
section()
protected abstract SELF
self()
void
Sets the value at the given path.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cc.carm.lib.configuration.source.section.ConfigureSection
childPath, computeSection, computeSection, computeSection, computeSection, contains, containsValue, createSection, createSection, createSection, forEach, fullPath, get, get, get, get, getBoolean, getBoolean, getByte, getByte, getByteList, getChar, getChar, getCharList, getCollection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getList, getList, getLong, getLong, getLongList, getSection, getSectionList, getShort, getShort, getString, getString, getStringList, isBoolean, isByte, isChar, isDouble, isEmpty, isFloat, isInt, isList, isLong, isRoot, isSection, isShort, isString, isType, keys, size, stream, stream, stream, values
-
Field Details
-
holder
@NotNull protected final @NotNull ConfigurationHolder<? extends SELF extends ConfigureSource<SECTION,ORIGINAL, holderSELF>> -
lastUpdateMillis
protected long lastUpdateMillis
-
-
Constructor Details
-
ConfigureSource
protected ConfigureSource(@NotNull @NotNull ConfigurationHolder<? extends SELF> holder, long lastUpdateMillis)
-
-
Method Details
-
holder
-
reload
- Throws:
Exception
-
self
-
original
- Returns:
- The original configuration object.
-
section
- Returns:
- The root
ConfigureSection
, which represents the entire configuration.
-
save
Save the whole configuration.- Throws:
Exception
- If any error occurs while saving.
-
onReload
Reload the configuration.
This used for implementation, for external usage, usereload()
- Throws:
Exception
- If any error occurs while reloading.
-
pathSeparator
public char pathSeparator()Description copied from interface:ConfigureSection
Get the path separator for the section.- Specified by:
pathSeparator
in interfaceConfigureSection
- Returns:
- The path separator
-
getLastUpdateMillis
public long getLastUpdateMillis() -
isExpired
public boolean isExpired(long parsedTime) -
parent
Source also represents the root section, so it has no parent- Specified by:
parent
in interfaceConfigureSection
- Returns:
- null
-
path
Description copied from interface:ConfigureSection
Get the current section's path fromConfigureSection.parent()
of this section.- Specified by:
path
in interfaceConfigureSection
- Returns:
- The current path of this section, if
ConfigureSection.isRoot()
, return empty string.
-
getValues
Description copied from interface:ConfigureSection
Gets a set containing all values in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSection
s (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Specified by:
getValues
in interfaceConfigureSection
- Parameters:
deep
- Whether to get a deep list.- Returns:
- Map of data values contained within this Section.
-
getKeys
Description copied from interface:ConfigureSection
Gets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSection
s (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Specified by:
getKeys
in interfaceConfigureSection
- Parameters:
deep
- Whether to get a deep list.- Returns:
- Set of keys contained within this Section.
-
asMap
Description copied from interface:ConfigureSection
Get this section as a map.In this map, child
ConfigureSection
s will also be represented asMap
s.- Specified by:
asMap
in interfaceConfigureSection
- Returns:
- Map of data values contained within this Section.
-
createSection
@NotNull public @NotNull ConfigureSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?, ?> data) Description copied from interface:ConfigureSection
Creates a newConfigureSection
with specified values.The
ConfigureSection.parent()
of the new section will be this section.This section will not be saved until
ConfigureSection.set(String, Object)
is called.If you want to create and use a section and set it to this section, use
ConfigureSection.computeSection(String)
.- Specified by:
createSection
in interfaceConfigureSection
- Parameters:
data
- The data to be used to create section.- Returns:
- Newly created section
-
set
Description copied from interface:ConfigureSection
Sets the value at the given path.Null values will be kept, if you want to remove a value use
ConfigureSection.remove(String)
Path separator depends on holder'sStandardOptions.PATH_SEPARATOR
- Specified by:
set
in interfaceConfigureSection
- Parameters:
path
- The path to set the value at.value
- The value to set.
-
remove
Description copied from interface:ConfigureSection
Removes the value at the given path.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR
- Specified by:
remove
in interfaceConfigureSection
- Parameters:
path
- The path to remove the value at.
-
get
Description copied from interface:ConfigureSection
Get the origin value of the path.- Specified by:
get
in interfaceConfigureSection
- Parameters:
path
- The path to get the value from.- Returns:
- The value at the path, or null if not found.
-