Interface Comments


@NonExtendable @AvailableSince("0.6.0") public interface Comments
Holds a mutable collection of comments bound to a specific TOML expression
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(@NotNull Comment comment)
    Adds a comment.
    default void
    add(@NotNull CommentPosition position, @NotNull String content)
    Creates and adds a comment
    default void
    addInline(@NotNull String content)
    Alias for add(CommentPosition.INLINE, content)
    default void
    addPost(@NotNull String content)
    Alias for add(CommentPosition.POST, content)
    default void
    addPre(@NotNull String content)
    Alias for add(CommentPosition.PRE, content)
    @NotNull @Unmodifiable List<Comment>
    all()
    Provides an immutable list of all comments held by this object, in the order they would appear in a document.
    void
    Removes all comments
    void
    clear(@NotNull CommentPosition position)
    Removes all comments of the given position.
    static @NotNull Comments
    copyOf(@NotNull Comments other)
     
    int
    Reports the total number of comments, equivalent to all().length()
    static @NotNull Comments
     
    @NotNull @Unmodifiable List<Comment>
    get(@NotNull CommentPosition position)
    Provides an immutable list of all comments of the given position in insertion order.
    default @Nullable String
    Gets the content of the INLINE comment, if any is set.
    default void
    setInline(@Nullable String content)
    Sets the content of the inline comment, or clears it if null
  • Method Details

    • empty

      @Contract("-> new") @NotNull static @NotNull Comments empty()
    • copyOf

      @Contract("_ -> new") @AvailableSince("0.6.4") @NotNull static @NotNull Comments copyOf(@NotNull @NotNull Comments other)
    • count

      int count()
      Reports the total number of comments, equivalent to all().length()
    • all

      @NotNull @NotNull @Unmodifiable List<Comment> all()
      Provides an immutable list of all comments held by this object, in the order they would appear in a document. Comments are sorted by position, then by insertion order.
    • get

      @NotNull @NotNull @Unmodifiable List<Comment> get(@NotNull @NotNull CommentPosition position)
      Provides an immutable list of all comments of the given position in insertion order.
    • getInline

      @Nullable default @Nullable String getInline()
      Gets the content of the INLINE comment, if any is set.
    • clear

      void clear()
      Removes all comments
    • clear

      void clear(@NotNull @NotNull CommentPosition position)
      Removes all comments of the given position.
    • add

      void add(@NotNull @NotNull Comment comment)
      Adds a comment. If the position of the comment is INLINE, any existing inline comment is replaced.
    • add

      default void add(@NotNull @NotNull CommentPosition position, @NotNull @NotNull String content)
      Creates and adds a comment
      Parameters:
      position - Position of the comment. If INLINE, any existing inline comment is replaced.
      content - Content of the comment
      See Also:
    • addPre

      default void addPre(@NotNull @NotNull String content)
      Alias for add(CommentPosition.PRE, content)
      See Also:
    • addInline

      default void addInline(@NotNull @NotNull String content)
      Alias for add(CommentPosition.INLINE, content)
      See Also:
    • setInline

      default void setInline(@Nullable @Nullable String content)
      Sets the content of the inline comment, or clears it if null
    • addPost

      default void addPost(@NotNull @NotNull String content)
      Alias for add(CommentPosition.POST, content)
      See Also: