Class CommentData

java.lang.Object
space.arim.dazzleconf.backend.CommentData

public final class CommentData extends Object
The comments on a data entry or configuration class.

This class is immutable, meaning that methods which appear to change data return a new object instead.

  • Method Details

    • isEmpty

      public boolean isEmpty()
      Gets whether there are no comments
      Returns:
      true if no comments exist
    • getAt

      public @NonNull List<@NonNull String> getAt(@NonNull CommentLocation location)
      Gets the comments at the specified location.

      The returned value may be immutable, or it may be a mutable copy.

      Parameters:
      location - the location
      Returns:
      the comment lines, or an empty list if none exist
    • setAt

      public @NonNull CommentData setAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines)
      Attaches comments and returns a new object.

      If an empty list is specified, this function will clear the comments at the specified location.

      Parameters:
      location - where the comments are situated
      lines - the comment lines to specify at this location
      Returns:
      a new instance of this class with the comments set
    • setAt

      public @NonNull CommentData setAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines)
      Attaches comments and returns a new object.

      If an empty array is specified, this function will clear the comments at the specified location.

      Parameters:
      location - where the comments are situated
      lines - the comment lines to specify at this location
      Returns:
      a new instance of this class with the comments set
    • appendAt

      public @NonNull CommentData appendAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines)
      Appends comments at the following location and returns a new object.

      If existing comments are set, they will come first.

      Parameters:
      location - where the comments will be situated
      lines - the comment lines to add at this location
      Returns:
      a new instance of this class with the comments appended
    • appendAt

      public @NonNull CommentData appendAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines)
      Appends comments at the following location and returns a new object.

      If existing comments are set, they will come first.

      Parameters:
      location - where the comments will be situated
      lines - the comment lines to add at this location
      Returns:
      a new instance of this class with the comments appended
    • clearAt

      public @NonNull CommentData clearAt(@NonNull CommentLocation @NonNull ... locations)
      Clears comments at some locations and returns a new object
      Parameters:
      locations - which comments to clear
      Returns:
      a new instance of this class with no comments at the specified locations
    • append

      public @NonNull CommentData append(@NonNull CommentData other)
      Appends another set of comments to this one.

      Any existing comments on this object will be placed first in the resulting product.

      Parameters:
      other - the other instance to append to this one
      Returns:
      a new instance with the given comments appended
    • buildFrom

      public static @NonNull CommentData buildFrom(@NonNull Comments @Nullable [] source)
      Makes an instance of this class according to Comments annotations.

      This function collects all the comments, in order, into a single object and returns it. If the argument array is null or empty, an empty object is returned.

      Parameters:
      source - the annotations to use
      Returns:
      a comments object
    • empty

      public static CommentData empty()
      Returns an empty instance of Comments
      Returns:
      an empty instance
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object