Class ConfigurationWrapper<T extends Configuration>

java.lang.Object
org.simpleyaml.configuration.ConfigurationWrapper<T>
Direct Known Subclasses:
YamlFileWrapper

public class ConfigurationWrapper<T extends Configuration> extends Object
  • Field Details

  • Constructor Details

    • ConfigurationWrapper

      protected ConfigurationWrapper(T configuration, String path, ConfigurationWrapper<T> parent)
    • ConfigurationWrapper

      public ConfigurationWrapper(T configuration, String path)
  • Method Details

    • path

      public ConfigurationWrapper<T> path(String path)
      Get a wrapper builder for the given child path.
      Parameters:
      path - child path of this section path, not null.
      Returns:
      the child path wrapper
      Throws:
      IllegalArgumentException - if path is null
    • set

      public ConfigurationWrapper<T> set(Object value)
      Set the given value to this path.

      If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.

      Parameters:
      value - new value to set the path to.
      Returns:
      this object, for chaining.
    • setChild

      public ConfigurationWrapper<T> setChild(String child, Object value)
      Set the given value to the provided child path.

      If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.

      Parameters:
      child - the child path of this section path.
      value - new value to set the child path to.
      Returns:
      this object, for chaining.
    • addDefault

      public ConfigurationWrapper<T> addDefault(Object value)
      Sets the default value of this path.

      If no source Configuration was provided as a default collection, then a new MemoryConfiguration will be created to hold the new 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 section at the path, replacing anything that may have existed there previously.

      Parameters:
      value - value to set the default to.
      Returns:
      this object, for chaining.
    • addDefault

      public ConfigurationWrapper<T> addDefault(String child, Object value)
      Sets the default value of the provided child path.

      If no source Configuration was provided as a default collection, then a new MemoryConfiguration will be created to hold the new 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 section at the path, replacing anything that may have existed there previously.

      Parameters:
      child - the child path of this section path.
      value - value to set the default to.
      Returns:
      this object, for chaining.
    • createSection

      public ConfigurationWrapper<T> createSection()
      Creates an empty ConfigurationSection at this path.

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

      Returns:
      this object, for chaining.
    • createSection

      public ConfigurationWrapper<T> createSection(String child)
      Creates an empty ConfigurationSection at the provided child path.

      Any value that was previously set at this will be overwritten. If the previous value was itself a ConfigurationSection, it will be orphaned.

      Parameters:
      child - the child path of this section path.
      Returns:
      this object, for chaining.
    • getCurrentPath

      public String getCurrentPath()
      Gets the current path.
      Returns:
      this path.
    • parent

      public ConfigurationWrapper<T> parent()
      Returns to the parent.
      Returns:
      the parent path wrapper, or null if this path does not have a parent.
    • childPath

      protected final String childPath(String child)
    • apply

    • applyToChild

      protected ConfigurationWrapper<T> applyToChild(ConfigurationWrapper.ApplyToPath method, String path)
    • set

    • setToChild

      protected ConfigurationWrapper<T> setToChild(ConfigurationWrapper.SetToPath method, String child, Object value)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object