Class ConfigureSource<SECTION extends ConfigureSection,ORIGINAL,SELF extends ConfigureSource<SECTION,ORIGINAL,SELF>>
- java.lang.Object
-
- cc.carm.lib.configuration.source.section.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
public abstract class ConfigureSource<SECTION extends ConfigureSection,ORIGINAL,SELF extends ConfigureSource<SECTION,ORIGINAL,SELF>> extends java.lang.Object implements ConfigureSection
ConfigureSource represents the source of configuration, which can be a file, a database, or any other source.
-
-
Field Summary
Fields Modifier and Type Field Description protected @NotNull ConfigurationHolder<? extends SELF>holderprotected longlastUpdateMillis
-
Constructor Summary
Constructors Modifier Constructor Description protectedConfigureSource(@NotNull ConfigurationHolder<? extends SELF> holder, long lastUpdateMillis)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(@NotNull java.lang.String path)Check if the value of given path is present.@Nullable java.lang.Objectget(@NotNull java.lang.String path)Get the origin value of the path.longgetLastUpdateMillis()@Nullable java.util.List<?>getList(@NotNull java.lang.String path)Get the value as aListfrom the specified path.@Nullable ConfigureSectiongetSection(@NotNull java.lang.String path)Get the value as aConfigureSectionfrom the specified path.@NotNull java.util.Map<java.lang.String,java.lang.Object>getValues(boolean deep)Gets a set containing all values in this section.@NotNull ConfigurationHolder<? extends SELF>holder()booleanisExpired(long parsedTime)protected abstract voidonReload()Reload the configuration.abstract ORIGINALoriginal()@Nullable ConfigureSectionparent()Source also represents the root section, so it has no parentcharpathSeparator()voidreload()voidremove(@NotNull java.lang.String path)Removes the value at the given path.abstract voidsave()Save the whole configuration.abstract SECTIONsection()protected abstract SELFself()voidset(@NotNull java.lang.String path, @Nullable java.lang.Object value)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
get, get, get, get, getBoolean, getBoolean, getByte, getByte, getByteList, getChar, getChar, getCharList, getCollection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getLong, getLong, getLongList, getShort, getShort, getString, getString, getStringList, isBoolean, isByte, isChar, isDouble, isFloat, isInt, isList, isLong, isSection, isShort, isString, isType, stream, stream
-
-
-
-
Field Detail
-
holder
@NotNull protected final @NotNull ConfigurationHolder<? extends SELF extends ConfigureSource<SECTION,ORIGINAL,SELF>> holder
-
lastUpdateMillis
protected long lastUpdateMillis
-
-
Constructor Detail
-
ConfigureSource
protected ConfigureSource(@NotNull @NotNull ConfigurationHolder<? extends SELF> holder, long lastUpdateMillis)
-
-
Method Detail
-
holder
@NotNull public @NotNull ConfigurationHolder<? extends SELF> holder()
-
reload
public void reload() throws java.lang.Exception- Throws:
java.lang.Exception
-
self
@Contract(pure=true) @Internal @NotNull protected abstract SELF self()
-
original
@Contract(pure=true) @NotNull public abstract ORIGINAL original()
- Returns:
- The original configuration object.
-
section
@NotNull public abstract SECTION section()
- Returns:
- The root
ConfigureSection, which represents the entire configuration.
-
save
public abstract void save() throws java.lang.ExceptionSave the whole configuration.- Throws:
java.lang.Exception- If any error occurs while saving.
-
onReload
@OverrideOnly protected abstract void onReload() throws java.lang.ExceptionReload the configuration.
This used for implementation, for external usage, usereload()- Throws:
java.lang.Exception- If any error occurs while reloading.
-
pathSeparator
public char pathSeparator()
-
getLastUpdateMillis
public long getLastUpdateMillis()
-
isExpired
public boolean isExpired(long parsedTime)
-
parent
@Contract(pure=true, value="->null") @Nullable public @Nullable ConfigureSection parent()Source also represents the root section, so it has no parent- Specified by:
parentin interfaceConfigureSection- Returns:
- null
-
getValues
@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.Object> getValues(boolean deep)
Description copied from interface:ConfigureSectionGets a set containing all values in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSections (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:
getValuesin interfaceConfigureSection- Parameters:
deep- Whether to get a deep list.- Returns:
- Map of data values contained within this Section.
-
set
public void set(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object value)Description copied from interface:ConfigureSectionSets 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:
setin interfaceConfigureSection- Parameters:
path- The path to set the value at.value- The value to set.
-
contains
public boolean contains(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionCheck if the value of given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
containsin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present, false otherwise.
-
remove
public void remove(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionRemoves the value at the given path.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
removein interfaceConfigureSection- Parameters:
path- The path to remove the value at.
-
getList
@Nullable public @Nullable java.util.List<?> getList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionGet the value as aListfrom the specified path.- Specified by:
getListin interfaceConfigureSection- Parameters:
path- The path to get theList.- Returns:
- The list if the path exists and is a list, otherwise null.
-
getSection
@Nullable public @Nullable ConfigureSection getSection(@NotNull @NotNull java.lang.String path)
Description copied from interface:ConfigureSectionGet the value as aConfigureSectionfrom the specified path.- Specified by:
getSectionin interfaceConfigureSection- Parameters:
path- The path to get the section.- Returns:
- The section if the path exists and is a section, otherwise null.
-
get
@Nullable public @Nullable java.lang.Object get(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionGet the origin value of the path.- Specified by:
getin interfaceConfigureSection- Parameters:
path- The path to get the value from.- Returns:
- The value at the path, or null if not found.
-
-