Class YamlFileWrapper

java.lang.Object
org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
org.simpleyaml.configuration.file.YamlFileWrapper

public class YamlFileWrapper extends ConfigurationWrapper<YamlFile>
An alternative API to set values along with comments for a path.
 
 yamlFile.path("test.hello")
         .set("Hello")
         .comment("Block comment")
         .commentSide("Side comment");
 
 
See Also:
  • Constructor Details

  • Method Details

    • comment

      public YamlFileWrapper comment(String comment)
      Set a block comment above the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of YamlConfiguration.options() YamlConfigurationOptions.commentFormatter().

      Parameters:
      comment - the block comment to add, # character is not needed
      Returns:
      this object, for chaining.
    • comment

      public YamlFileWrapper comment(String comment, YamlCommentFormatter yamlCommentFormatter)
      Set a block comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of the provided YamlCommentFormatter.

      Parameters:
      comment - the block comment to add, # prefix is not needed
      yamlCommentFormatter - the comment formatter to use
      Returns:
      this object, for chaining.
    • comment

      public YamlFileWrapper comment(String comment, YamlCommentFormat yamlCommentFormat)
      Set a block comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of the provided YamlCommentFormat.

      Parameters:
      comment - the block comment to add, # prefix is not needed
      yamlCommentFormat - the comment format to use
      Returns:
      this object, for chaining.
    • commentSide

      public YamlFileWrapper commentSide(String comment)
      Set a side comment above the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of YamlConfiguration.options() YamlConfigurationOptions.commentFormatter().

      Parameters:
      comment - the side comment to add, # symbol is not needed
      Returns:
      this object, for chaining.
    • commentSide

      public YamlFileWrapper commentSide(String comment, YamlCommentFormatter yamlCommentFormatter)
      Set a side comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of the provided YamlCommentFormatter.

      Parameters:
      comment - the side comment to add, # prefix is not needed
      yamlCommentFormatter - the comment formatter to use
      Returns:
      this object, for chaining.
    • commentSide

      public YamlFileWrapper commentSide(String comment, YamlCommentFormat yamlCommentFormat)
      Set a side comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.

      Comment format will follow the rules of the provided YamlCommentFormat.

      Parameters:
      comment - the side to add, # prefix is not needed
      yamlCommentFormat - the comment format to use
      Returns:
      this object, for chaining.
    • blankLine

      public YamlFileWrapper blankLine()
      Set a blank line at the beginning of the block comment. If currently there is no block comment for this path then it sets "\n" as the block comment.
      Returns:
      this object, for chaining.
    • path

      public YamlFileWrapper path(String path)
      Description copied from class: ConfigurationWrapper
      Get a wrapper builder for the given child path.
      Overrides:
      path in class ConfigurationWrapper<YamlFile>
      Parameters:
      path - child path of this section path, not null.
      Returns:
      the child path wrapper
    • set

      public YamlFileWrapper set(Object value)
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      set in class ConfigurationWrapper<YamlFile>
      Parameters:
      value - new value to set the path to.
      Returns:
      this object, for chaining.
    • setChild

      public YamlFileWrapper setChild(String child, Object value)
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      setChild in class ConfigurationWrapper<YamlFile>
      Parameters:
      child - the child path of this section path.
      value - new value to set the child path to.
      Returns:
      this object, for chaining.
    • set

      public YamlFileWrapper set(Object value, QuoteStyle quoteStyle)
      Set the given value to this path.

      The value will be represented with the specified quote style in the configuration file.

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

      Null value is valid and will not remove the key, this is different to set(Object). Instead, a null value will be written as a yaml empty null value.

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

      public YamlFileWrapper setChild(String child, Object value, QuoteStyle quoteStyle)
      Set the given value to the provided child path.

      The value will be represented with the specified quote style in the configuration file.

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

      Null value is valid and will not remove the key, this is different to setChild(String, Object). Instead, a null value will be written as a yaml empty null value.

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

      public YamlFileWrapper addDefault(Object value)
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      addDefault in class ConfigurationWrapper<YamlFile>
      Parameters:
      value - value to set the default to.
      Returns:
      this object, for chaining.
    • addDefault

      public YamlFileWrapper addDefault(String child, Object value)
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      addDefault in class ConfigurationWrapper<YamlFile>
      Parameters:
      child - the child path of this section path.
      value - value to set the default to.
      Returns:
      this object, for chaining.
    • createSection

      public YamlFileWrapper createSection()
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      createSection in class ConfigurationWrapper<YamlFile>
      Returns:
      this object, for chaining.
    • createSection

      public YamlFileWrapper createSection(String child)
      Description copied from class: ConfigurationWrapper
      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.

      Overrides:
      createSection in class ConfigurationWrapper<YamlFile>
      Parameters:
      child - the child path of this section path.
      Returns:
      this object, for chaining.
    • parent

      public YamlFileWrapper parent()
      Description copied from class: ConfigurationWrapper
      Returns to the parent.
      Overrides:
      parent in class ConfigurationWrapper<YamlFile>
      Returns:
      the parent path wrapper, or null if this path does not have a parent.