Record Class ExcelCellComment

java.lang.Object
java.lang.Record
io.github.dornol.excelkit.excel.ExcelCellComment
Record Components:
text - the comment text (must be non-null)
author - optional comment author (POI stores it in the XML but Excel does not surface it in the note tooltip; kept for completeness)
width - comment box width in cells; 0 means default (2)
height - comment box height in rows; 0 means default (3)

public record ExcelCellComment(String text, @Nullable String author, int width, int height) extends Record
Represents a cell comment (note) to be added to an Excel cell.

Use the static factory of(String) and the wither-style methods author(String) / size(int, int) to build comments fluently.


 ExcelCellComment.of("Enter in YYYY-MM-DD").size(3, 5)
 ExcelCellComment.of("Reviewed").author("System").size(2, 2)
 
Since:
0.6.0
  • Constructor Details

    • ExcelCellComment

      public ExcelCellComment(String text, @Nullable String author, int width, int height)
      Validates invariants.
  • Method Details

    • of

      public static ExcelCellComment of(String text)
      Creates a comment with the given text, no author, and default size.
      Parameters:
      text - the comment text
      Returns:
      a new ExcelCellComment
    • author

      public ExcelCellComment author(@Nullable String author)
      Returns a copy with the given author.
      Parameters:
      author - the author name
      Returns:
      a new ExcelCellComment
    • size

      public ExcelCellComment size(int width, int height)
      Returns a copy with the given box size (in cells × rows).

      Pass 0 for either dimension to use the default (2 cols × 3 rows).

      Parameters:
      width - width in cells
      height - height in rows
      Returns:
      a new ExcelCellComment
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • author

      public @Nullable String author()
      Returns the value of the author record component.
      Returns:
      the value of the author record component
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component