Class CommentMode

java.lang.Object
space.arim.dazzleconf.ext.snakeyaml.CommentMode

public final class CommentMode extends Object
Determines the way in which comments will be written
  • Method Summary

    Modifier and Type
    Method
    Description
    A mode which will use an alternative yaml writer (other than snakeyaml) to write both the comments of the configuration as well as the entries themselves.
    alternativeWriter(String commentFormat)
    A mode which will use an alternative yaml writer (other than snakeyaml) to write both the comments of the configuration as well as the entries themselves.
    boolean
    Whether this comment mode is the same as another
    A mode which has full support for comments, taking advantage of functionality introduced in snakeyaml 1.28.
    int
     
    A mode which will write the comment header on the top level configuration, but which is unable to write any further comments.
    boolean
    Whether this comment mode fully comments, including the comment header as well as comments on individual entries
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • supportsComments

      public boolean supportsComments()
      Whether this comment mode fully comments, including the comment header as well as comments on individual entries
      Returns:
      whether this mode fully supports comments
    • equals

      public boolean equals(Object o)
      Whether this comment mode is the same as another
      Overrides:
      equals in class Object
      Parameters:
      o - the object to determine equality with
      Returns:
      true if equal, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • headerOnly

      public static CommentMode headerOnly()
      A mode which will write the comment header on the top level configuration, but which is unable to write any further comments.

      This is the default mode, because it is most compatible with old versions of snakeyaml, and is highly stable.
      Returns:
      a comment mode which writes the top comment header only
    • alternativeWriter

      public static CommentMode alternativeWriter(String commentFormat)
      A mode which will use an alternative yaml writer (other than snakeyaml) to write both the comments of the configuration as well as the entries themselves.

      This implies full comment support, but note that the alternative yaml writer, while tested and workable, does not have the same level of stability as snakeyaml itself.
      The Comment Format
      The comment format is used for writing comments. It must be a String.format compatible format string.

      By default, comments are formatted as in the example: ' # Comment here'. This corresponds to the comment format " # %s"

      Note well: it is caller's responsibility to ensure the comment format results in valid YAML.
      Parameters:
      commentFormat - the comment format with which to write comments
      Returns:
      a comment mode using the alternative yaml writer
      Throws:
      IllegalFormatException - if the comment format is an illegal format string
    • alternativeWriter

      public static CommentMode alternativeWriter()
      A mode which will use an alternative yaml writer (other than snakeyaml) to write both the comments of the configuration as well as the entries themselves.

      This implies full comment support, but note that the alternative yaml writer, while tested and workable, does not have the same level of stability as snakeyaml itself.

      Uses the default comment format, i.e. ' # Comment here'
      Returns:
      a comment mode using the alternative yaml writer
    • fullComments

      public static CommentMode fullComments()
      A mode which has full support for comments, taking advantage of functionality introduced in snakeyaml 1.28. If the version of snakeyaml in use is less than version 1.28, this option will fail at runtime (an undefined exception will be thrown at a later time)
      Returns:
      a mode which fully supports comments using snakeyaml 1.28 or a later version