Package io.github.dornol.excelkit.excel
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)- 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;0means default (2)height- comment box height in rows;0means 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 Summary
ConstructorsConstructorDescriptionExcelCellComment(String text, @Nullable String author, int width, int height) Validates invariants. -
Method Summary
Modifier and TypeMethodDescription@Nullable Stringauthor()Returns the value of theauthorrecord component.Returns a copy with the given author.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intheight()Returns the value of theheightrecord component.static ExcelCellCommentCreates a comment with the given text, no author, and default size.size(int width, int height) Returns a copy with the given box size (in cells × rows).text()Returns the value of thetextrecord component.final StringtoString()Returns a string representation of this record class.intwidth()Returns the value of thewidthrecord component.
-
Constructor Details
-
ExcelCellComment
Validates invariants.
-
-
Method Details
-
of
Creates a comment with the given text, no author, and default size.- Parameters:
text- the comment text- Returns:
- a new
ExcelCellComment
-
author
Returns a copy with the given author.- Parameters:
author- the author name- Returns:
- a new
ExcelCellComment
-
size
Returns a copy with the given box size (in cells × rows).Pass
0for either dimension to use the default (2 cols × 3 rows).- Parameters:
width- width in cellsheight- height in rows- Returns:
- a new
ExcelCellComment
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
author
Returns the value of theauthorrecord component.- Returns:
- the value of the
authorrecord component
-
width
public int width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
height
public int height()Returns the value of theheightrecord component.- Returns:
- the value of the
heightrecord component
-