java.lang.Object
org.bspfsystems.yamlconfiguration.configuration.MemorySection
All Implemented Interfaces:
ConfigurationSection
Direct Known Subclasses:
MemoryConfiguration

public class MemorySection extends Object implements ConfigurationSection
Represents an implementation of a configuration section that is only stored in-memory.

Synchronized with the commit on 07-June-2022.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs an empty memory section for use as a root configuration section.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDefault(@NotNull String path, @Nullable Object value)
    Sets the default value in the root at the given path as provided.
    protected final void
    Clears the internal map.
    final boolean
    contains(@NotNull String path)
    Checks if this configuration section contains the given path.
    final boolean
    contains(@NotNull String path, boolean ignoreDefault)
    Checks if this configuration section contains the given path.
    static @NotNull String
    createPath(@NotNull ConfigurationSection section, @Nullable String key)
    Creates a full path to the given configuration section from its root configuration.
    static @NotNull String
    createPath(@NotNull ConfigurationSection section, @Nullable String key, @Nullable ConfigurationSection relative)
    Creates a relative path to the given configuration section from the given relative section.
    final @NotNull ConfigurationSection
    createSection(@NotNull String path)
    Creates an empty configuration section at the given path.
    final @NotNull ConfigurationSection
    createSection(@NotNull String path, @NotNull Map<?,?> map)
    Creates a configuration section at the given path, with the given values.
    final @Nullable Object
    get(@NotNull String path)
    Gets the value at the given path.
    final @Nullable Object
    get(@NotNull String path, @Nullable Object def)
    Gets the value at the given path, returning the given default value if one has not been set.
    final boolean
    getBoolean(@NotNull String path)
    Gets the boolean value at the given path.
    final boolean
    getBoolean(@NotNull String path, boolean def)
    Gets the boolean value at the given path.
    final @NotNull List<Boolean>
    getBooleanList(@NotNull String path)
    Gets the list of booleans at the given path.
    final byte
    getByte(@NotNull String path)
    Gets the byte value at the given path.
    final byte
    getByte(@NotNull String path, byte def)
    Gets the byte value at the given path.
    final @NotNull List<Byte>
    getByteList(@NotNull String path)
    Gets the list of bytes at the given path.
    final char
    getChar(@NotNull String path)
    Gets the char value at the given path.
    final char
    getChar(@NotNull String path, char def)
    Gets the char value at the given path.
    final @NotNull List<Character>
    getCharList(@NotNull String path)
    Gets the list of chars at the given path.
    final @NotNull @UnmodifiableView List<String>
    getComments(@NotNull String path)
    Gets the comments by path.
    final @Nullable ConfigurationSection
    Gets the configuration section value at the given path.
    final @NotNull String
    Gets the path of this configuration section from its root configuration.
    final @Nullable ConfigurationSection
    Gets the equivalent configuration section from the default configuration defined in ConfigurationSection.getRoot().
    final double
    getDouble(@NotNull String path)
    Gets the double value at the given path.
    final double
    getDouble(@NotNull String path, double def)
    Gets the double value at the given path.
    final @NotNull List<Double>
    getDoubleList(@NotNull String path)
    Gets the list of doubles at the given path.
    final float
    getFloat(@NotNull String path)
    Gets the float value at the given path.
    final float
    getFloat(@NotNull String path, float def)
    Gets the float value at the given path.
    final @NotNull List<Float>
    getFloatList(@NotNull String path)
    Gets the list of floats at the given path.
    final @NotNull @UnmodifiableView List<String>
    getInlineComments(@NotNull String path)
    Gets the inline comments by path.
    final int
    getInt(@NotNull String path)
    Gets the int value at the given path.
    final int
    getInt(@NotNull String path, int def)
    Gets the int value at the given path.
    final @NotNull List<Integer>
    getIntList(@NotNull String path)
    Gets the list of ints at the given path.
    final @NotNull @UnmodifiableView Set<String>
    getKeys(boolean deep)
    Gets a set containing a copy of all keys in this configuration section.
    final @Nullable List<?>
    getList(@NotNull String path)
    Gets the list value at the given path.
    final @Nullable List<?>
    getList(@NotNull String path, @Nullable List<?> def)
    Gets the list value at the given path.
    final long
    getLong(@NotNull String path)
    Gets the long value at the given path.
    final long
    getLong(@NotNull String path, long def)
    Gets the long value at the given path.
    final @NotNull List<Long>
    getLongList(@NotNull String path)
    Gets the list of longs at the given path.
    final @NotNull List<Map<?,?>>
    getMapList(@NotNull String path)
    Gets the list of maps at the given path.
    final @NotNull String
    Gets the name of this individual configuration section in its path.
    final <T> T
    getObject(@NotNull String path, @NotNull Class<T> clazz)
    Gets the value of type T at the given path.
    final <T> T
    getObject(@NotNull String path, @NotNull Class<T> clazz, T def)
    Gets the value of type T at the given path.
    Gets the parent configuration section that directly contains this section.
    final @Nullable Configuration
    Gets the root configuration that contains this configuration section.
    final <T extends ConfigurationSerializable>
    T
    getSerializable(@NotNull String path, @NotNull Class<T> clazz)
    Gets the configuration serializable value of type T at the given path.
    final <T extends ConfigurationSerializable>
    T
    getSerializable(@NotNull String path, @NotNull Class<T> clazz, T def)
    Gets the configuration serializable value of type T value at the given path.
    final short
    getShort(@NotNull String path)
    Gets the short value at the given path.
    final short
    getShort(@NotNull String path, short def)
    Gets the short value at the given path.
    final @NotNull List<Short>
    getShortList(@NotNull String path)
    Gets the list of shorts at the given path.
    final @Nullable String
    getString(@NotNull String path)
    Gets the string value at the given path.
    final @Nullable String
    getString(@NotNull String path, @Nullable String def)
    Gets the string value at the given path.
    final @NotNull List<String>
    getStringList(@NotNull String path)
    Gets the list of strings at the given path.
    final @NotNull @UnmodifiableView Map<String,Object>
    getValues(boolean deep)
    Gets a map containing a copy of all keys and their respective values for this configuration section.
    final boolean
    isBoolean(@NotNull String path)
    Checks if the value at the given path is a boolean.
    final boolean
    isByte(@NotNull String path)
    Checks if the value at the given path is a byte.
    final boolean
    isChar(@NotNull String path)
    Checks if the value at the given path is a char.
    final boolean
    Checks if the value at the given path is a configuration section.
    final boolean
    isDouble(@NotNull String path)
    Checks if the value at the given path is a double.
    final boolean
    isFloat(@NotNull String path)
    Checks if the value at the given path is a float.
    final boolean
    isInt(@NotNull String path)
    Checks if the value at the given path is an int.
    final boolean
    isList(@NotNull String path)
    Checks if the value at the given path is a generic list.
    final boolean
    isLong(@NotNull String path)
    Checks if the value at the given path is a long.
    final boolean
    isNumber(@NotNull String path)
    Checks if the value at the given path is a number.
    final boolean
    isSet(@NotNull String path)
    Checks if this configuration section has a value set for the given path.
    final boolean
    isShort(@NotNull String path)
    Checks if the value at the given path is a short.
    final boolean
    isString(@NotNull String path)
    Checks if the value at the given path is a string.
    final void
    set(@NotNull String path, @Nullable Object value)
    Sets the given path to the given value.
    final void
    setComments(@NotNull String path, @Nullable List<String> comments)
    Sets the comments at the given path.
    final void
    setInlineComments(@NotNull String path, @Nullable List<String> inlineComments)
    Sets the inline comments at the given path.
    final @NotNull String
    Creates a string representation of this memory section.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MemorySection

      protected MemorySection() throws IllegalStateException
      Constructs an empty memory section for use as a root configuration section.

      NOTE: If the new memory section is not a configuration, an illegal argument exception will be thrown, as a configuration section cannot be orphaned by default, and all configuration sections must contain a root configuration.

      Throws:
      IllegalStateException - If the new memory section is not a configuration.
  • Method Details

    • getKeys

      @NotNull public final @NotNull @UnmodifiableView Set<String> getKeys(boolean deep)
      Gets a set containing a copy of all keys in this configuration section.

      If deep is set to true, then the set will contain all keys within this configuration section as well as the keys of any children sections of this section, working recursively down through each child's potential children. As a result, all the keys will be the fully-qualified paths.

      If deep is set to false, then the set will contain only the keys of any values of this configuration section, even if those values themselves are children configuration sections.

      In either case, the set will be unmodifiable, and any updates to the keys of this configuration section will not be reflected in the returned set.

      Specified by:
      getKeys in interface ConfigurationSection
      Parameters:
      deep - true if the set is to contain the keys of the children configuration section(s) of this section (recursive), false otherwise.
      Returns:
      A copy of the set of keys contained within this configuration section.
    • getValues

      @NotNull public final @NotNull @UnmodifiableView Map<String,Object> getValues(boolean deep)
      Gets a map containing a copy of all keys and their respective values for this configuration section.

      If deep is set to true, then the map will contain all key-value pairings within this configuration section, as well as the key-value pairings of any children sections of this section, working recursively down through each child's potential children. As a result, all the keys will be the fully-qualified paths.

      If deep is set to false, then the map will contain only the key-value pairings of this configuration section, even if those values themselves are children configuration sections.

      In either case, the map will be unmodifiable, and any updates to the keys, values, or the pairings of this configuration section will not be reflected in the returned set.

      Specified by:
      getValues in interface ConfigurationSection
      Parameters:
      deep - true if the map is to contain the key-value pairings of the children configuration section(s) of this section (recursive), false otherwise.
      Returns:
      A copy of the map of key-value pairings contained within this configuration section.
    • getCurrentPath

      @NotNull public final @NotNull String getCurrentPath()
      Gets the path of this configuration section from its root configuration.

      If this configuration section is a configuration itself, this will return an empty string.

      If this configuration section is no longer contained within a root configuration for any reason, such as being replaced with a different value, this may return null.

      This will return the fully-qualified path of this section. If only the final part of the path of this section is desired, please use ConfigurationSection.getName().

      Specified by:
      getCurrentPath in interface ConfigurationSection
      Returns:
      The fully-qualified path of this configuration section relative to its root configuration, or null if this section is orphaned.
    • getName

      @NotNull public final @NotNull String getName()
      Gets the name of this individual configuration section in its path.

      This will always be the final part of ConfigurationSection.getCurrentPath(), unless this configuration section is orphaned.

      Specified by:
      getName in interface ConfigurationSection
      Returns:
      The name of this configuration section.
    • getRoot

      @Nullable public final @Nullable Configuration getRoot()
      Gets the root configuration that contains this configuration section.

      If this configuration section is itself a configuration, this will return this section.

      If this configuration section is no longer contained within a root configuration for any reason, such as being replaced with a different value, this may return null.

      Specified by:
      getRoot in interface ConfigurationSection
      Returns:
      The root configuration containing this configuration section, or null if this section is orphaned.
    • getParent

      @Nullable public @Nullable ConfigurationSection getParent()
      Gets the parent configuration section that directly contains this section.

      If this configuration section is itself a configuration, this will return null.

      If this configuration section is no longer contained within a root configuration for any reason, such as being replaced with a different value, this may return null.

      Specified by:
      getParent in interface ConfigurationSection
      Returns:
      The parent configuration section containing this section, or null if this section does not have a parent.
    • getDefaultSection

      @Nullable public final @Nullable ConfigurationSection getDefaultSection()
      Gets the equivalent configuration section from the default configuration defined in ConfigurationSection.getRoot().

      If the root configuration contains no defaults, or the defaults do not contain a value for this configuration section's path, or the value at this path is not itself a configuration section, this will return null.

      Specified by:
      getDefaultSection in interface ConfigurationSection
      Returns:
      The equivalent configuration section in the default configuration, or null if one does not exist or is not the correct type.
    • addDefault

      public void addDefault(@NotNull @NotNull String path, @Nullable @Nullable Object value)
      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 new memory configuration will be created to hold the given default value.

      If value is null, the value will be removed from the default configuration source.

      If the value as returned by ConfigurationSection.getDefaultSection() is null, then this will create a new configuration section at the path, replacing anything that may have existed there previously.

      Specified by:
      addDefault in interface ConfigurationSection
      Parameters:
      path - The path of the default value to set.
      value - The value to set the default to.
    • getComments

      @NotNull public final @NotNull @UnmodifiableView List<String> getComments(@NotNull @NotNull String path)
      Gets the comments by path.

      If no comments exist, and empty list will be returned. A null entry represents an empty line and an empty string represents an empty comment line (# with nothing after it).

      The returned list will be unmodifiable, and any changes to the underlying comments in this configuration section will not be reflected in the returned list.

      Specified by:
      getComments in interface ConfigurationSection
      Parameters:
      path - The path of the comments to get.
      Returns:
      The comments as a list, where every entry represents a separate line.
    • getInlineComments

      @NotNull public final @NotNull @UnmodifiableView List<String> getInlineComments(@NotNull @NotNull String path)
      Gets the inline comments by path.

      If no comments exist, an empty list will be returned. A null entry represents an empty line and an empty string represents an empty comment line (# with nothing after it).

      The returned list will be unmodifiable, and any changes to the underlying inline comments in this configuration section will not be reflected in the returned list.

      Specified by:
      getInlineComments in interface ConfigurationSection
      Parameters:
      path - The path of the comments to get.
      Returns:
      The inline comments as a list, where every entry represents a separate line.
    • setComments

      public final void setComments(@NotNull @NotNull String path, @Nullable @Nullable List<String> comments)
      Sets the comments at the given path.

      If the given list is null itself, any existing comments will be removed. Otherwise, the existing comments will be replaced with the contents of the given list, regardless of the previous comment values.

      A null entry in the list will result in an empty line, and an empty string as an entry will result in an empty comment line (# with nothing after it).

      Specified by:
      setComments in interface ConfigurationSection
      Parameters:
      path - The path of the comments to set.
      comments - The new comments to set at the given path, where every entry in the list represents one line. null to remove any existing comments.
    • setInlineComments

      public final void setInlineComments(@NotNull @NotNull String path, @Nullable @Nullable List<String> inlineComments)
      Sets the inline comments at the given path.

      If the given list is null itself, any existing inline comments will be removed. Otherwise, the existing inline comments will be replaced with the contents of the given list, regardless of the previous comment values.

      A null entry in the list will result in an empty line, and an empty string as an entry will result in an empty comment line (# with nothing after it).

      Specified by:
      setInlineComments in interface ConfigurationSection
      Parameters:
      path - The path of the inline comments to set.
      inlineComments - The new inline comments to set at the given path, where every entry in the list represents one line. null to remove any existing inline comments.
    • createSection

      @NotNull public final @NotNull ConfigurationSection createSection(@NotNull @NotNull String path)
      Creates an empty configuration section at the given path.

      Any value that was previously set at this path will be overwritten. If the previous value was a configuration section itself, that section will be orphaned.

      Specified by:
      createSection in interface ConfigurationSection
      Parameters:
      path - The path to create the configuration section at.
      Returns:
      The newly-created configuration section.
    • createSection

      @NotNull public final @NotNull ConfigurationSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?,?> map)
      Creates a configuration section at the given path, with the given values.

      Any value that was previously set at this path will be overwritten. If the previous value was a configuration section itself, that section will be orphaned.

      Specified by:
      createSection in interface ConfigurationSection
      Parameters:
      path - The path to create the configuration section at.
      map - The key-value pairings to place in the newly-created configuration section.
      Returns:
      The newly-created configuration section.
    • isSet

      public final boolean isSet(@NotNull @NotNull String path)
      Checks if this configuration section has a value set for the given path.

      If the value for the given path does not exist but a default value has been set, this will still return false. If the status of a default value is desired, please use ConfigurationSection.contains(String).

      Specified by:
      isSet in interface ConfigurationSection
      Parameters:
      path - The path to check for existence.
      Returns:
      true if this configuration section contains the given path, regardless of having a default, false otherwise.
      See Also:
    • set

      public final void set(@NotNull @NotNull String path, @Nullable @Nullable Object value)
      Sets the given path to the given value. Any existing value will be replaced, regardless of what it and the new given value are.

      If the given value is null, the entry will be removed.

      The given value may not be a configuration or a configuration section. If a new configuration section is desired, please use ConfigurationSection.createSection(String).

      Specified by:
      set in interface ConfigurationSection
      Parameters:
      path - The path to the given value.
      value - The new value to store at the given path.
    • contains

      public final boolean contains(@NotNull @NotNull String path)
      Checks if this configuration section contains the given path.

      If the value for the given path does not exist but a default value has been set, this will return true. If the existence of a default value is to be ignored, please use ConfigurationSection.contains(String, boolean), where ignoreDefault is true.

      Specified by:
      contains in interface ConfigurationSection
      Parameters:
      path - The path to check for existence.
      Returns:
      true if this configuration section contains the given path, either via an actual value or default value being set, false otherwise.
      See Also:
    • contains

      public final boolean contains(@NotNull @NotNull String path, boolean ignoreDefault)
      Checks if this configuration section contains the given path.

      If true is given for ignoreDefault, then this will return true only if a value has been set for the given path.

      If false is given for ignoreDefaults, then this will return true if a value has been set for the given path, or if a default value has been set for the given path.

      Specified by:
      contains in interface ConfigurationSection
      Parameters:
      path - The path to check for existence.
      ignoreDefault - true if any default values should be ignored when checking for a value at the path, false otherwise.
      Returns:
      true if this configuration section contains an actual value at the given path, or if a default value has been set and ignoreDefault is false, false otherwise.
    • get

      @Nullable public final @Nullable Object get(@NotNull @NotNull String path)
      Gets the value at the given path.

      If a value has not been set at the given path, but a default value has been set, this will return the default value. If no value and no default value have been set, this will return null.

      Specified by:
      get in interface ConfigurationSection
      Parameters:
      path - The path of the value to retrieve.
      Returns:
      The requested value.
    • get

      @Contract("_, !null -> !null") @Nullable public final @Nullable Object get(@NotNull @NotNull String path, @Nullable @Nullable Object def)
      Gets the value at the given path, returning the given default value if one has not been set.

      If a value has not been set at the given path, the given default value will be returned, regardless of whether a default value exists in the root configuration.

      Specified by:
      get in interface ConfigurationSection
      Parameters:
      path - The path of the value to retrieve.
      def - The value to use as a default.
      Returns:
      The requested value.
    • isBoolean

      public final boolean isBoolean(@NotNull @NotNull String path)
      Checks if the value at the given path is a boolean.

      If the value exists at the given path but is not a boolean, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check the default value and return appropriately.

      Specified by:
      isBoolean in interface ConfigurationSection
      Parameters:
      path - The path of the boolean to check.
      Returns:
      true if a boolean value exists, or if there is no value, a default has been set, and it is a boolean, false otherwise.
    • getBoolean

      public final boolean getBoolean(@NotNull @NotNull String path)
      Gets the boolean value at the given path.

      If the value exists at the given path but is not a boolean, this will return false.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getBoolean in interface ConfigurationSection
      Parameters:
      path - The path of the boolean to retrieve.
      Returns:
      The requested boolean.
    • getBoolean

      public final boolean getBoolean(@NotNull @NotNull String path, boolean def)
      Gets the boolean value at the given path.

      If the value exists at the given path but is not a boolean, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getBoolean in interface ConfigurationSection
      Parameters:
      path - The path of the boolean to retrieve.
      def - The boolean to use as the default.
      Returns:
      The requested boolean.
    • isNumber

      public final boolean isNumber(@NotNull @NotNull String path)
      Checks if the value at the given path is a number.

      If the value exists at the given path but is not a number, this will return false.

      If the value does not exist at the give path but a default value has been set, this will check that value and return appropriately.

      This method is meant to be a more generic check than the specific number-based checks below, such as ConfigurationSection.isByte(String), or ConfigurationSection.isDouble(String). Those methods check to see if the requested value (or default) is of the exact type, whereas this method will simply check for a number.

      Specified by:
      isNumber in interface ConfigurationSection
      Parameters:
      path - The path of the number to check.
      Returns:
      true if a number value exists, or if there is no value, a default has been set, and it is a number, false otherwise.
      See Also:
    • isByte

      public final boolean isByte(@NotNull @NotNull String path)
      Checks if the value at the given path is a byte.

      If the value exists at the given path but is not a byte, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically a byte. If the value is another type of number, this will return false. To check for a generic number please use ConfigurationSection.isNumber(String).

      Specified by:
      isByte in interface ConfigurationSection
      Parameters:
      path - The path of the byte to check.
      Returns:
      true if a byte value exists, or if there is no value, a default has been set, and it is a byte, false otherwise.
      See Also:
    • getByte

      public final byte getByte(@NotNull @NotNull String path)
      Gets the byte value at the given path.

      If the value exists at the given path but is not a byte, this will return (byte) 0.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getByte in interface ConfigurationSection
      Parameters:
      path - The path of the byte to retrieve.
      Returns:
      The requested byte.
    • getByte

      public final byte getByte(@NotNull @NotNull String path, byte def)
      Gets the byte value at the given path.

      If the value exists at the given path but is not a byte, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getByte in interface ConfigurationSection
      Parameters:
      path - The path of the byte to retrieve.
      def - The byte to use as the default.
      Returns:
      The requested byte.
    • isShort

      public final boolean isShort(@NotNull @NotNull String path)
      Checks if the value at the given path is a short.

      If the value exists at the given path but is not a short, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically a short. If the value is another type of number, this will return false. To check for a generic number, please use ConfigurationSection.isNumber(String).

      Specified by:
      isShort in interface ConfigurationSection
      Parameters:
      path - The path of the short to check.
      Returns:
      true if a short value exists, or if there is no value, a default has been set, and it is a short, false otherwise.
      See Also:
    • getShort

      public final short getShort(@NotNull @NotNull String path)
      Gets the short value at the given path.

      If the value exists at the given path but is not a short, this will return (short) 0.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getShort in interface ConfigurationSection
      Parameters:
      path - The path of the short to retrieve.
      Returns:
      The requested short.
    • getShort

      public final short getShort(@NotNull @NotNull String path, short def)
      Gets the short value at the given path.

      If the value exists at the given path but is not a short, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getShort in interface ConfigurationSection
      Parameters:
      path - The path of the short to retrieve.
      def - The short to use as the default.
      Returns:
      The requested short.
    • isInt

      public final boolean isInt(@NotNull @NotNull String path)
      Checks if the value at the given path is an int.

      If the value exists at the given path but is not an int, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically an int. If the value is another type of number, this will return false. To check for a generic number, please use ConfigurationSection.isNumber(String).

      Specified by:
      isInt in interface ConfigurationSection
      Parameters:
      path - The path of the int to check.
      Returns:
      true if an int value exists, or if there is no value, a default has been set, and it is an int, false otherwise.
      See Also:
    • getInt

      public final int getInt(@NotNull @NotNull String path)
      Gets the int value at the given path.

      If the value exists at the given path but is not an int, this will return 0.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getInt in interface ConfigurationSection
      Parameters:
      path - The path of the int to retrieve.
      Returns:
      The requested int.
    • getInt

      public final int getInt(@NotNull @NotNull String path, int def)
      Gets the int value at the given path.

      If the value exists at the given path but is not an int, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root Configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getInt in interface ConfigurationSection
      Parameters:
      path - The path of the int to retrieve.
      def - The int to use as the default.
      Returns:
      The requested int.
    • isLong

      public final boolean isLong(@NotNull @NotNull String path)
      Checks if the value at the given path is a long.

      If the value exists at the given path but is not a long, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically a long. If the value is another type of number, this will return false. To check for a generic number, please use ConfigurationSection.isNumber(String).

      Specified by:
      isLong in interface ConfigurationSection
      Parameters:
      path - The path of the long to check.
      Returns:
      true if a long value exists, or if there is no value, a default has been set, and it is a long, false otherwise.
      See Also:
    • getLong

      public final long getLong(@NotNull @NotNull String path)
      Gets the long value at the given path.

      If the value exists at the given path but is not a long, this will return 0L.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getLong in interface ConfigurationSection
      Parameters:
      path - The path of the long to retrieve.
      Returns:
      The requested long.
    • getLong

      public final long getLong(@NotNull @NotNull String path, long def)
      Gets the long value at the given path.

      If the value exists at the given path but is not a long, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getLong in interface ConfigurationSection
      Parameters:
      path - The path of the long to retrieve.
      def - The long to use as the default.
      Returns:
      The requested long.
    • isFloat

      public final boolean isFloat(@NotNull @NotNull String path)
      Checks if the value at the given path is a float.

      If the value exists at the given path but is not a float, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically a float. If the value is another type of number, this will return false. To check for a generic number, please use ConfigurationSection.isNumber(String).

      Specified by:
      isFloat in interface ConfigurationSection
      Parameters:
      path - The path of the float to check.
      Returns:
      true if a float value exists, or if there is no value, a default has been set, and it is a float, false otherwise.
      See Also:
    • getFloat

      public final float getFloat(@NotNull @NotNull String path)
      Gets the float value at the given path.

      If the value exists at the given path but is not a float, this will return 0.0F.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getFloat in interface ConfigurationSection
      Parameters:
      path - The path of the float to retrieve.
      Returns:
      The requested float.
    • getFloat

      public final float getFloat(@NotNull @NotNull String path, float def)
      Gets the float value at the given path.

      If the value exists at the given path but is not a float, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getFloat in interface ConfigurationSection
      Parameters:
      path - The path of the float to retrieve.
      def - The float to use as the default.
      Returns:
      The requested float.
    • isDouble

      public final boolean isDouble(@NotNull @NotNull String path)
      Checks if the value at the given path is a double.

      If the value exists at the given path but is not a double, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      This method will check to see if the requested value (or default) is specifically a double. If the value is another type of number, this will return false. To check for a generic number, please use ConfigurationSection.isNumber(String).

      Specified by:
      isDouble in interface ConfigurationSection
      Parameters:
      path - The path of the double to check.
      Returns:
      true if a double value exists, or if there is no value, a default has been set, and it is a double, false otherwise.
      See Also:
    • getDouble

      public final double getDouble(@NotNull @NotNull String path)
      Gets the double value at the given path.

      If the value exists at the given path but is not a double, this will return 0.0D.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getDouble in interface ConfigurationSection
      Parameters:
      path - The path of the double to retrieve.
      Returns:
      The requested double.
    • getDouble

      public final double getDouble(@NotNull @NotNull String path, double def)
      Gets the double value at the given path.

      If the value exists at the given path but is not a double, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getDouble in interface ConfigurationSection
      Parameters:
      path - The path of the double to retrieve.
      def - The double to use as the default.
      Returns:
      The requested double.
    • isChar

      public final boolean isChar(@NotNull @NotNull String path)
      Checks if the value at the given path is a char.

      If the value exists at the given path but is not a char, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      Specified by:
      isChar in interface ConfigurationSection
      Parameters:
      path - The path of the char to check.
      Returns:
      true if a char value exists, or if there is no value, a default has been set, and it is a char, false otherwise.
    • getChar

      public final char getChar(@NotNull @NotNull String path)
      Gets the char value at the given path.

      If the value exists at the given path but is not a char, this will return .

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getChar in interface ConfigurationSection
      Parameters:
      path - The path of the char to retrieve.
      Returns:
      The requested char.
    • getChar

      public final char getChar(@NotNull @NotNull String path, char def)
      Gets the char value at the given path.

      If the value exists at the given path but is not a char, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getChar in interface ConfigurationSection
      Parameters:
      path - The path of the char to retrieve.
      def - The char to use as the default.
      Returns:
      The requested char.
    • isString

      public final boolean isString(@NotNull @NotNull String path)
      Checks if the value at the given path is a string.

      If the value exists at the given path but is not a string, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      Specified by:
      isString in interface ConfigurationSection
      Parameters:
      path - The path of the string to check.
      Returns:
      true if a string value exists, or if there is no value, a default has been set, and it is a string, false otherwise.
    • getString

      @Nullable public final @Nullable String getString(@NotNull @NotNull String path)
      Gets the string value at the given path.

      If the value exists at the given path but is not a string, this will return null.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getString in interface ConfigurationSection
      Parameters:
      path - The path of the string to retrieve.
      Returns:
      The requested string.
    • getString

      @Contract("_, !null -> !null") @Nullable public final @Nullable String getString(@NotNull @NotNull String path, @Nullable @Nullable String def)
      Gets the string value at the given path.

      If the value exists at the given path but is not a string, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getString in interface ConfigurationSection
      Parameters:
      path - The path of the string to retrieve.
      def - The string to use as the default.
      Returns:
      The requested string.
    • isList

      public final boolean isList(@NotNull @NotNull String path)
      Checks if the value at the given path is a generic list.

      If the value exists at the given path but is not a list, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      Specified by:
      isList in interface ConfigurationSection
      Parameters:
      path - The path of the list to check.
      Returns:
      true if a list value exists, or if there is no value, a default has been set, and it is a list, false otherwise.
    • getList

      @Nullable public final @Nullable List<?> getList(@NotNull @NotNull String path)
      Gets the list value at the given path.

      If the value exists at the given path but is not a list, this will return null.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getList in interface ConfigurationSection
      Parameters:
      path - The path of the list to retrieve.
      Returns:
      The requested list.
    • getList

      @Contract("_, !null -> !null") @Nullable public final @Nullable List<?> getList(@NotNull @NotNull String path, @Nullable @Nullable List<?> def)
      Gets the list value at the given path.

      If the value exists at the given path but is not a list, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getList in interface ConfigurationSection
      Parameters:
      path - The path of the list to retrieve.
      def - The list to use as the default.
      Returns:
      The requested list.
    • isConfigurationSection

      public final boolean isConfigurationSection(@NotNull @NotNull String path)
      Checks if the value at the given path is a configuration section.

      If the value exists at the given path but is not a configuration section, this will return false.

      If the value does not exist at the given path but a default value has been set, this will check that value and return appropriately.

      Specified by:
      isConfigurationSection in interface ConfigurationSection
      Parameters:
      path - The path of the configuration section to check.
      Returns:
      true if a configuration section value exists, or if there is no value, a default has been set, and it is a configuration section. false otherwise.
    • getConfigurationSection

      @Nullable public final @Nullable ConfigurationSection getConfigurationSection(@NotNull @NotNull String path)
      Gets the configuration section value at the given path.

      If the value exists at the given path but is not a configuration section, this will return null.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getConfigurationSection in interface ConfigurationSection
      Parameters:
      path - The path of the configuration section to retrieve.
      Returns:
      The requested configuration section.
    • getObject

      @Nullable public final <T> T getObject(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz)
      Gets the value of type T at the given path.

      If the value exists at the given path but is not of type T, this will return null.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Note: Using this method to get a string is not the same as ConfigurationSection.getString(String), as the latter internally converts all non-strings to strings, whereas this method will only give the requested value if it is an instance of T. The same applies to any number, as they are cast to a number internally, and then the correct value is returned.

      Specified by:
      getObject in interface ConfigurationSection
      Type Parameters:
      T - The type of the requested value.
      Parameters:
      path - The path of the value of type T to retrieve.
      clazz - The class of type T of the requested value.
      Returns:
      The requested value of type T.
    • getObject

      @Contract("_, _, !null -> !null") @Nullable public final <T> T getObject(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz, @Nullable T def)
      Gets the value of type T at the given path.

      If the value exists at the given path but is not of type T, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Note: Using this method to get a string is not the same as ConfigurationSection.getString(String), as the latter internally converts all non-strings to strings, whereas this method will only give the requested value if it is an instance of T. The same applies to any number, as they are cast to a number internally, and then the correct value is returned.

      Specified by:
      getObject in interface ConfigurationSection
      Type Parameters:
      T - The type of the requested value.
      Parameters:
      path - The path of the value of type T to retrieve.
      clazz - The class of type T of the requested value.
      def - The value of type T to use as the default.
      Returns:
      The requested value of type T.
    • getSerializable

      @Nullable public final <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz)
      Gets the configuration serializable value of type T at the given path.

      If the value exists at the given path but is not a configuration serializable of type T, this will return null.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      Specified by:
      getSerializable in interface ConfigurationSection
      Type Parameters:
      T - The type of the requested configuration serializable.
      Parameters:
      path - The path of the configuration serializable value of type T to retrieve.
      clazz - The class of type T of the requested configuration serializable.
      Returns:
      The requested configuration serializable value of type T.
    • getSerializable

      @Contract("_, _, !null -> !null") @Nullable public final <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz, @Nullable T def)
      Gets the configuration serializable value of type T value at the given path.

      If the value exists at the given path but is not a configuration serializable value of type T, or if the value does not exist at the given path, this will return the given default.

      If a default value has been set in the root configuration, it will be ignored, even if the given path does not have a set value.

      Specified by:
      getSerializable in interface ConfigurationSection
      Type Parameters:
      T - The type of the requested configuration serializable.
      Parameters:
      path - The path of the configuration serializable value of type T to retrieve.
      clazz - The class of type T of the requested configuration serializable.
      def - The configuration serializable value of type T to use as the default.
      Returns:
      The requested configuration serializable value of type T.
    • getBooleanList

      @NotNull public final @NotNull List<Boolean> getBooleanList(@NotNull @NotNull String path)
      Gets the list of booleans at the given path.

      If the value exists at the given path but is not a list of booleans, this will attempt to cast any values into a boolean, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getBooleanList in interface ConfigurationSection
      Parameters:
      path - The path of the list of booleans to retrieve.
      Returns:
      The requested list of booleans.
    • getByteList

      @NotNull public final @NotNull List<Byte> getByteList(@NotNull @NotNull String path)
      Gets the list of bytes at the given path.

      If the value exists at the given path but is not a list of bytes, this will attempt to cast any values into a byte, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getByteList in interface ConfigurationSection
      Parameters:
      path - The path of the list of bytes to retrieve.
      Returns:
      The requested list of bytes.
    • getShortList

      @NotNull public final @NotNull List<Short> getShortList(@NotNull @NotNull String path)
      Gets the list of shorts at the given path.

      If the value exists at the given path but is not a list of shorts, this will attempt to cast any values into a short, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getShortList in interface ConfigurationSection
      Parameters:
      path - The path of the list of shorts to retrieve.
      Returns:
      The requested list of shorts.
    • getIntList

      @NotNull public final @NotNull List<Integer> getIntList(@NotNull @NotNull String path)
      Gets the list of ints at the given path.

      If the value exists at the given path but is not a list of ints, this will attempt to cast any values into an int, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getIntList in interface ConfigurationSection
      Parameters:
      path - The path of the list of ints to retrieve.
      Returns:
      The requested list of ints.
    • getLongList

      @NotNull public final @NotNull List<Long> getLongList(@NotNull @NotNull String path)
      Gets the list of longs at the given path.

      If the value exists at the given path but is not a list of longs, this will attempt to cast any values into a long, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getLongList in interface ConfigurationSection
      Parameters:
      path - The path of the list of longs to retrieve.
      Returns:
      The requested list of longs.
    • getFloatList

      @NotNull public final @NotNull List<Float> getFloatList(@NotNull @NotNull String path)
      Gets the list of floats at the given path.

      If the value exists at the given path but is not a list of floats, this will attempt to cast any values into a float, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getFloatList in interface ConfigurationSection
      Parameters:
      path - The path of the list of floats to retrieve.
      Returns:
      The requested list of floats.
    • getDoubleList

      @NotNull public final @NotNull List<Double> getDoubleList(@NotNull @NotNull String path)
      Gets the list of doubles at the given path.

      If the value exists at the given path but is not a list of doubles, this will attempt to cast any values into a double, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getDoubleList in interface ConfigurationSection
      Parameters:
      path - The path of the list of doubles to retrieve.
      Returns:
      The requested list of doubles.
    • getCharList

      @NotNull public final @NotNull List<Character> getCharList(@NotNull @NotNull String path)
      Gets the list of chars at the given path.

      If the value exists at the given path but is not a list of chars, this will attempt to cast any values into a char, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getCharList in interface ConfigurationSection
      Parameters:
      path - The path of the list of chars to retrieve.
      Returns:
      The requested list of chars.
    • getStringList

      @NotNull public final @NotNull List<String> getStringList(@NotNull @NotNull String path)
      Gets the list of strings at the given path.

      If the value exists at the given path but is not a list of strings, this will attempt to cast any values into a string, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getStringList in interface ConfigurationSection
      Parameters:
      path - The path of the list of strings to retrieve.
      Returns:
      The requested list of strings.
    • getMapList

      @NotNull public final @NotNull List<Map<?,?>> getMapList(@NotNull @NotNull String path)
      Gets the list of maps at the given path.

      If the value exists at the given path but is not a list of maps, this will attempt to cast any values into a map, if possible. It may miss on any values that are not compatible.

      If the value does not exist at the given path, but a default value has been set, this will check that value and return similar to the above.

      If the value does not exist at the given path and no default value has been set, this will return an empty list.

      Specified by:
      getMapList in interface ConfigurationSection
      Parameters:
      path - The path of the list of maps to retrieve.
      Returns:
      The requested list of maps.
    • clear

      protected final void clear()
      Clears the internal map.
    • toString

      @NotNull public final @NotNull String toString()
      Creates a string representation of this memory section.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this memory section.
    • createPath

      @NotNull public static @NotNull String createPath(@NotNull @NotNull ConfigurationSection section, @Nullable @Nullable String key)
      Creates a full path to the given configuration section from its root configuration.

      You may use this method for any given configuration section, not only this memory section.

      Parameters:
      section - The configuration section to create a path for.
      key - The name of the given configuration section.
      Returns:
      The full path of the given configuration section from its root.
    • createPath

      @NotNull public static @NotNull String createPath(@NotNull @NotNull ConfigurationSection section, @Nullable @Nullable String key, @Nullable @Nullable ConfigurationSection relative)
      Creates a relative path to the given configuration section from the given relative section.

      You may use this method for any given configuration section, not only this memory section.

      Parameters:
      section - The configuration section to create a path for.
      key - The name of the given configuration section.
      relative - The configuration section to create the path relative to.
      Returns:
      The full path of the given configuration section from its root.