Class YamlFileWrapper

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

public class YamlFileWrapper extends org.simpleyaml.configuration.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)
      Overrides:
      path in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • set

      public YamlFileWrapper set(Object value)
      Overrides:
      set in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • setChild

      public YamlFileWrapper setChild(String child, Object value)
      Overrides:
      setChild in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • 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)
      Overrides:
      addDefault in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • addDefault

      public YamlFileWrapper addDefault(String child, Object value)
      Overrides:
      addDefault in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • createSection

      public YamlFileWrapper createSection()
      Overrides:
      createSection in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • createSection

      public YamlFileWrapper createSection(String child)
      Overrides:
      createSection in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>
    • parent

      public YamlFileWrapper parent()
      Overrides:
      parent in class org.simpleyaml.configuration.ConfigurationWrapper<YamlFile>