Class AbstractMapSection<R extends AbstractMapSection<R>>

java.lang.Object
cc.carm.lib.configuration.source.section.AbstractMapSection<R>
All Implemented Interfaces:
ConfigureSection
Direct Known Subclasses:
MemorySection, SourcedSection

public abstract class AbstractMapSection<R extends AbstractMapSection<R>> extends Object implements ConfigureSection
  • Field Details

  • Constructor Details

    • AbstractMapSection

      protected AbstractMapSection(@Nullable R parent, @NotNull @NotNull String path)
  • Method Details

    • migrate

      public void migrate(Map<?,?> data)
    • self

      @NotNull public abstract R self()
    • createSection

      @NotNull public abstract R 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
    • path

      @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.
    • contains

      public boolean contains(@NotNull @NotNull String path)
      Description copied from interface: ConfigureSection
      Check if the given path is present.

      Path separator depends on holder's StandardOptions.PATH_SEPARATOR

      Specified by:
      contains in interface ConfigureSection
      Parameters:
      path - The path to check.
      Returns:
      True if the value is present, false otherwise.
    • data

      @NotNull public @NotNull Map<String,Object> data()
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ConfigureSection
      Gets if this section is empty.
      Specified by:
      isEmpty in interface ConfigureSection
      Returns:
      True if this section is empty, false otherwise.
    • size

      public int size(boolean deep)
      Description copied from interface: ConfigureSection
      Gets the number of keys in this section.
      Specified by:
      size in interface ConfigureSection
      Returns:
      Number of keys in this section.
    • asMap

      @NotNull public @UnmodifiableView @NotNull 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.
    • parent

      @Nullable public R parent()
      Description copied from interface: ConfigureSection
      Gets the parent section of this section.

      For root sections, this will return null.

      Specified by:
      parent in interface ConfigureSection
      Returns:
      Parent section, or null if this is a root section.
    • getValues

      @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

      @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.
    • set

      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

      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

      @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.
    • mappingValues

      protected static Map<String,Object> mappingValues(@NotNull @NotNull AbstractMapSection<?> section, @Nullable @Nullable String parent, boolean deep, String pathSeparator)
      Map the values of the children of the section to the output map.
      Parameters:
      section - The section to map the values from
      parent - The parent path
      deep - If the mapping should be deep
    • mappingKeys

      protected static Set<String> mappingKeys(@NotNull @NotNull AbstractMapSection<?> section, @Nullable @Nullable String parent, boolean deep, String pathSeparator)