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 Object implements ConfigureSection
ConfigureSource represents the source of configuration, which can be a file, a database, or any other source.
See Also:
  • Field Details Link icon

  • Constructor Details Link icon

    • ConfigureSource Link icon

      protected ConfigureSource(@NotNull @NotNull ConfigurationHolder<? extends SELF> holder, long lastUpdateMillis)
  • Method Details Link icon

    • holder Link icon

      @NotNull public @NotNull ConfigurationHolder<? extends SELF> holder()
    • reload Link icon

      public void reload() throws Exception
      Throws:
      Exception
    • self Link icon

      @Contract(pure=true) @Internal @NotNull protected abstract SELF self()
    • original Link icon

      @Contract(pure=true) @NotNull public abstract ORIGINAL original()
      Returns:
      The original configuration object.
    • section Link icon

      @NotNull public abstract SECTION section()
      Returns:
      The root ConfigureSection, which represents the entire configuration.
    • save Link icon

      public abstract void save() throws Exception
      Save the whole configuration.
      Throws:
      Exception - If any error occurs while saving.
    • onReload Link icon

      @OverrideOnly protected abstract void onReload() throws Exception
      Reload the configuration.
      This used for implementation, for external usage, use reload()
      Throws:
      Exception - If any error occurs while reloading.
    • pathSeparator Link icon

      public char pathSeparator()
      Description copied from interface: ConfigureSection
      Get the path separator for the section.
      Specified by:
      pathSeparator in interface ConfigureSection
      Returns:
      The path separator
    • getLastUpdateMillis Link icon

      public long getLastUpdateMillis()
    • isExpired Link icon

      public boolean isExpired(long parsedTime)
    • parent Link icon

      @Contract(pure=true, value="->null") @Nullable public @Nullable ConfigureSection parent()
      Source also represents the root section, so it has no parent
      Specified by:
      parent in interface ConfigureSection
      Returns:
      null
    • path Link icon

      @NotNull public @NotNull String path()
      Description copied from interface: ConfigureSection
      Get the current section's path from ConfigureSection.parent() of this section.
      Specified by:
      path in interface ConfigureSection
      Returns:
      The current path of this section, if ConfigureSection.isRoot(), return empty string.
    • getValues Link icon

      @NotNull public @NotNull Map<String,Object> getValues(boolean deep)
      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 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:
      getValues in interface ConfigureSection
      Parameters:
      deep - Whether to get a deep list.
      Returns:
      Map of data values contained within this Section.
    • getKeys Link icon

      @NotNull public @NotNull @UnmodifiableView Set<String> getKeys(boolean deep)
      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 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:
      getKeys in interface ConfigureSection
      Parameters:
      deep - Whether to get a deep list.
      Returns:
      Set of keys contained within this Section.
    • asMap Link icon

      @NotNull public @NotNull @UnmodifiableView Map<String,Object> asMap()
      Description copied from interface: ConfigureSection
      Get this section as a map.

      In this map, child ConfigureSections will also be represented as Maps.

      Specified by:
      asMap in interface ConfigureSection
      Returns:
      Map of data values contained within this Section.
    • createSection Link icon

      @NotNull public @NotNull ConfigureSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?,?> data)
      Description copied from interface: ConfigureSection
      Creates a new ConfigureSection 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 interface ConfigureSection
      Parameters:
      data - The data to be used to create section.
      Returns:
      Newly created section
    • set Link icon

      public void set(@NotNull @NotNull String path, @Nullable @Nullable Object value)
      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's StandardOptions.PATH_SEPARATOR

      Specified by:
      set in interface ConfigureSection
      Parameters:
      path - The path to set the value at.
      value - The value to set.
    • remove Link icon

      public void remove(@NotNull @NotNull String path)
      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 interface ConfigureSection
      Parameters:
      path - The path to remove the value at.
    • get Link icon

      @Nullable public @Nullable Object get(@NotNull @NotNull String path)
      Description copied from interface: ConfigureSection
      Get the origin value of the path.
      Specified by:
      get in interface ConfigureSection
      Parameters:
      path - The path to get the value from.
      Returns:
      The value at the path, or null if not found.