From 911d5772fada3f11f56ceb117bf86b3134d488c9 Mon Sep 17 00:00:00 2001 From: Bengbengbalabalabeng Date: Mon, 10 Aug 2026 17:09:48 +0800 Subject: [PATCH 1/4] refactor: make objects immutable and remove redundant methods --- .../property/ColumnWidthProperty.java | 10 +-- .../property/DateTimeFormatProperty.java | 15 +--- .../sheet/metadata/property/FontProperty.java | 40 ++++----- .../metadata/property/LoopMergeProperty.java | 13 +-- .../property/NumberFormatProperty.java | 13 +-- .../property/OnceAbsoluteMergeProperty.java | 19 ++-- .../metadata/property/RowHeightProperty.java | 10 +-- .../property/SheetFreezePaneProperty.java | 25 +++--- .../metadata/property/StyleProperty.java | 88 +++++++++---------- .../style/SheetFreezePaneStrategyTest.java | 12 --- 10 files changed, 95 insertions(+), 150 deletions(-) diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java index d85503d16..c62483dbc 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java @@ -25,8 +25,8 @@ package org.apache.fesod.sheet.metadata.property; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.ColumnWidth; /** @@ -35,13 +35,9 @@ * */ @Getter -@Setter +@AllArgsConstructor public class ColumnWidthProperty { - private Integer width; - - public ColumnWidthProperty(Integer width) { - this.width = width; - } + private final Integer width; public static ColumnWidthProperty build(ColumnWidth columnWidth) { if (columnWidth == null || columnWidth.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java index 4e2ad8ed7..a9d9f54d1 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java @@ -25,9 +25,8 @@ package org.apache.fesod.sheet.metadata.property; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.common.util.BooleanUtils; import org.apache.fesod.sheet.annotation.format.DateTimeFormat; @@ -37,16 +36,10 @@ * */ @Getter -@Setter -@EqualsAndHashCode +@AllArgsConstructor public class DateTimeFormatProperty { - private String format; - private Boolean use1904windowing; - - public DateTimeFormatProperty(String format, Boolean use1904windowing) { - this.format = format; - this.use1904windowing = use1904windowing; - } + private final String format; + private final Boolean use1904windowing; public static DateTimeFormatProperty build(DateTimeFormat dateTimeFormat) { if (dateTimeFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java index caee2655b..7d65bc5c2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java @@ -25,9 +25,7 @@ package org.apache.fesod.sheet.metadata.property; -import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.common.util.StringUtils; import org.apache.fesod.sheet.annotation.write.style.ContentFontStyle; import org.apache.fesod.sheet.annotation.write.style.HeadFontStyle; @@ -42,8 +40,6 @@ * */ @Getter -@Setter -@EqualsAndHashCode public class FontProperty { /** * The name for the font (i.e. Arial) @@ -108,26 +104,26 @@ public static FontProperty build(HeadFontStyle headFontStyle) { } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(headFontStyle.fontName())) { - styleProperty.setFontName(headFontStyle.fontName()); + styleProperty.fontName = headFontStyle.fontName(); } if (headFontStyle.fontHeightInPoints() >= 0) { - styleProperty.setFontHeightInPoints(headFontStyle.fontHeightInPoints()); + styleProperty.fontHeightInPoints = headFontStyle.fontHeightInPoints(); } - styleProperty.setItalic(headFontStyle.italic().getBooleanValue()); - styleProperty.setStrikeout(headFontStyle.strikeout().getBooleanValue()); + styleProperty.italic = headFontStyle.italic().getBooleanValue(); + styleProperty.strikeout = headFontStyle.strikeout().getBooleanValue(); if (headFontStyle.color() >= 0) { - styleProperty.setColor(headFontStyle.color()); + styleProperty.color = headFontStyle.color(); } if (headFontStyle.typeOffset() >= 0) { - styleProperty.setTypeOffset(headFontStyle.typeOffset()); + styleProperty.typeOffset = headFontStyle.typeOffset(); } if (headFontStyle.underline() >= 0) { - styleProperty.setUnderline(headFontStyle.underline()); + styleProperty.underline = headFontStyle.underline(); } if (headFontStyle.charset() >= 0) { - styleProperty.setCharset(headFontStyle.charset()); + styleProperty.charset = headFontStyle.charset(); } - styleProperty.setBold(headFontStyle.bold().getBooleanValue()); + styleProperty.bold = headFontStyle.bold().getBooleanValue(); return styleProperty; } @@ -137,26 +133,26 @@ public static FontProperty build(ContentFontStyle contentFontStyle) { } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(contentFontStyle.fontName())) { - styleProperty.setFontName(contentFontStyle.fontName()); + styleProperty.fontName = contentFontStyle.fontName(); } if (contentFontStyle.fontHeightInPoints() >= 0) { - styleProperty.setFontHeightInPoints(contentFontStyle.fontHeightInPoints()); + styleProperty.fontHeightInPoints = contentFontStyle.fontHeightInPoints(); } - styleProperty.setItalic(contentFontStyle.italic().getBooleanValue()); - styleProperty.setStrikeout(contentFontStyle.strikeout().getBooleanValue()); + styleProperty.italic = contentFontStyle.italic().getBooleanValue(); + styleProperty.strikeout = contentFontStyle.strikeout().getBooleanValue(); if (contentFontStyle.color() >= 0) { - styleProperty.setColor(contentFontStyle.color()); + styleProperty.color = contentFontStyle.color(); } if (contentFontStyle.typeOffset() >= 0) { - styleProperty.setTypeOffset(contentFontStyle.typeOffset()); + styleProperty.typeOffset = contentFontStyle.typeOffset(); } if (contentFontStyle.underline() >= 0) { - styleProperty.setUnderline(contentFontStyle.underline()); + styleProperty.underline = contentFontStyle.underline(); } if (contentFontStyle.charset() >= 0) { - styleProperty.setCharset(contentFontStyle.charset()); + styleProperty.charset = contentFontStyle.charset(); } - styleProperty.setBold(contentFontStyle.bold().getBooleanValue()); + styleProperty.bold = contentFontStyle.bold().getBooleanValue(); return styleProperty; } } diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java index 615aad543..a95faa3fb 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java @@ -25,8 +25,8 @@ package org.apache.fesod.sheet.metadata.property; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.ContentLoopMerge; /** @@ -35,21 +35,16 @@ * */ @Getter -@Setter +@AllArgsConstructor public class LoopMergeProperty { /** * Each row */ - private int eachRow; + private final int eachRow; /** * Extend column */ - private int columnExtend; - - public LoopMergeProperty(int eachRow, int columnExtend) { - this.eachRow = eachRow; - this.columnExtend = columnExtend; - } + private final int columnExtend; public static LoopMergeProperty build(ContentLoopMerge contentLoopMerge) { if (contentLoopMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java index 184cff8e9..a8bbefbfe 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java @@ -26,8 +26,8 @@ package org.apache.fesod.sheet.metadata.property; import java.math.RoundingMode; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.format.NumberFormat; /** @@ -36,15 +36,10 @@ * */ @Getter -@Setter +@AllArgsConstructor public class NumberFormatProperty { - private String format; - private RoundingMode roundingMode; - - public NumberFormatProperty(String format, RoundingMode roundingMode) { - this.format = format; - this.roundingMode = roundingMode; - } + private final String format; + private final RoundingMode roundingMode; public static NumberFormatProperty build(NumberFormat numberFormat) { if (numberFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java index 457e40373..6b9739bd2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java @@ -25,8 +25,8 @@ package org.apache.fesod.sheet.metadata.property; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.OnceAbsoluteMerge; /** @@ -35,31 +35,24 @@ * */ @Getter -@Setter +@AllArgsConstructor public class OnceAbsoluteMergeProperty { /** * First row */ - private int firstRowIndex; + private final int firstRowIndex; /** * Last row */ - private int lastRowIndex; + private final int lastRowIndex; /** * First column */ - private int firstColumnIndex; + private final int firstColumnIndex; /** * Last row */ - private int lastColumnIndex; - - public OnceAbsoluteMergeProperty(int firstRowIndex, int lastRowIndex, int firstColumnIndex, int lastColumnIndex) { - this.firstRowIndex = firstRowIndex; - this.lastRowIndex = lastRowIndex; - this.firstColumnIndex = firstColumnIndex; - this.lastColumnIndex = lastColumnIndex; - } + private final int lastColumnIndex; public static OnceAbsoluteMergeProperty build(OnceAbsoluteMerge onceAbsoluteMerge) { if (onceAbsoluteMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java index f2cb2068b..a2bef41f2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java @@ -25,8 +25,8 @@ package org.apache.fesod.sheet.metadata.property; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.ContentRowHeight; import org.apache.fesod.sheet.annotation.write.style.HeadRowHeight; @@ -36,13 +36,9 @@ * */ @Getter -@Setter +@AllArgsConstructor public class RowHeightProperty { - private Short height; - - public RowHeightProperty(Short height) { - this.height = height; - } + private final Short height; public static RowHeightProperty build(HeadRowHeight headRowHeight) { if (headRowHeight == null || headRowHeight.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java index 4d8490fb3..f7f80ece9 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java @@ -19,9 +19,8 @@ package org.apache.fesod.sheet.metadata.property; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.FreezePane; /** @@ -31,40 +30,38 @@ * It is typically built from the {@link FreezePane} annotation. */ @Getter -@Setter -@EqualsAndHashCode +@AllArgsConstructor public class SheetFreezePaneProperty { /** * Horizontal position of split. */ - private int colSplit; + private final int colSplit; /** * Vertical position of split. */ - private int rowSplit; + private final int rowSplit; /** * Left column visible in right pane. */ - private int leftmostColumn; + private final int leftmostColumn; /** * Top row visible in bottom pane */ - private int topRow; + private final int topRow; public static SheetFreezePaneProperty build(FreezePane freezePane) { if (freezePane == null) { return null; } - SheetFreezePaneProperty result = new SheetFreezePaneProperty(); - result.setColSplit(freezePane.colSplit()); - result.setRowSplit(freezePane.rowSplit()); - result.setLeftmostColumn(getOrDefault(freezePane.leftmostColumn(), freezePane.colSplit())); - result.setTopRow(getOrDefault(freezePane.topRow(), freezePane.rowSplit())); - return result; + return new SheetFreezePaneProperty( + freezePane.colSplit(), + freezePane.rowSplit(), + getOrDefault(freezePane.leftmostColumn(), freezePane.colSplit()), + getOrDefault(freezePane.topRow(), freezePane.rowSplit())); } private static Integer getOrDefault(Integer value, Integer defaultValue) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java index 7c1e8d637..5ef8af7e1 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java @@ -25,9 +25,7 @@ package org.apache.fesod.sheet.metadata.property; -import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.Setter; import org.apache.fesod.sheet.annotation.write.style.ContentStyle; import org.apache.fesod.sheet.annotation.write.style.HeadStyle; import org.apache.fesod.sheet.metadata.data.DataFormatData; @@ -46,8 +44,6 @@ * */ @Getter -@Setter -@EqualsAndHashCode public class StyleProperty { /** * Set the data format (must be a valid format). Built in formats are defined at {@link BuiltinFormats}. @@ -174,44 +170,44 @@ public static StyleProperty build(HeadStyle headStyle) { if (headStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(headStyle.dataFormat()); - styleProperty.setDataFormatData(dataFormatData); + styleProperty.dataFormatData = dataFormatData; } - styleProperty.setHidden(headStyle.hidden().getBooleanValue()); - styleProperty.setLocked(headStyle.locked().getBooleanValue()); - styleProperty.setQuotePrefix(headStyle.quotePrefix().getBooleanValue()); - styleProperty.setHorizontalAlignment(headStyle.horizontalAlignment().getPoiHorizontalAlignment()); - styleProperty.setWrapped(headStyle.wrapped().getBooleanValue()); - styleProperty.setVerticalAlignment(headStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); + styleProperty.hidden = headStyle.hidden().getBooleanValue(); + styleProperty.locked = headStyle.locked().getBooleanValue(); + styleProperty.quotePrefix = headStyle.quotePrefix().getBooleanValue(); + styleProperty.horizontalAlignment = headStyle.horizontalAlignment().getPoiHorizontalAlignment(); + styleProperty.wrapped = headStyle.wrapped().getBooleanValue(); + styleProperty.verticalAlignment = headStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); if (headStyle.rotation() >= 0) { - styleProperty.setRotation(headStyle.rotation()); + styleProperty.rotation = headStyle.rotation(); } if (headStyle.indent() >= 0) { - styleProperty.setIndent(headStyle.indent()); + styleProperty.indent = headStyle.indent(); } - styleProperty.setBorderLeft(headStyle.borderLeft().getPoiBorderStyle()); - styleProperty.setBorderRight(headStyle.borderRight().getPoiBorderStyle()); - styleProperty.setBorderTop(headStyle.borderTop().getPoiBorderStyle()); - styleProperty.setBorderBottom(headStyle.borderBottom().getPoiBorderStyle()); + styleProperty.borderLeft = headStyle.borderLeft().getPoiBorderStyle(); + styleProperty.borderRight = headStyle.borderRight().getPoiBorderStyle(); + styleProperty.borderTop = headStyle.borderTop().getPoiBorderStyle(); + styleProperty.borderBottom = headStyle.borderBottom().getPoiBorderStyle(); if (headStyle.leftBorderColor() >= 0) { - styleProperty.setLeftBorderColor(headStyle.leftBorderColor()); + styleProperty.leftBorderColor = headStyle.leftBorderColor(); } if (headStyle.rightBorderColor() >= 0) { - styleProperty.setRightBorderColor(headStyle.rightBorderColor()); + styleProperty.rightBorderColor = headStyle.rightBorderColor(); } if (headStyle.topBorderColor() >= 0) { - styleProperty.setTopBorderColor(headStyle.topBorderColor()); + styleProperty.topBorderColor = headStyle.topBorderColor(); } if (headStyle.bottomBorderColor() >= 0) { - styleProperty.setBottomBorderColor(headStyle.bottomBorderColor()); + styleProperty.bottomBorderColor = headStyle.bottomBorderColor(); } - styleProperty.setFillPatternType(headStyle.fillPatternType().getPoiFillPatternType()); + styleProperty.fillPatternType = headStyle.fillPatternType().getPoiFillPatternType(); if (headStyle.fillBackgroundColor() >= 0) { - styleProperty.setFillBackgroundColor(headStyle.fillBackgroundColor()); + styleProperty.fillBackgroundColor = headStyle.fillBackgroundColor(); } if (headStyle.fillForegroundColor() >= 0) { - styleProperty.setFillForegroundColor(headStyle.fillForegroundColor()); + styleProperty.fillForegroundColor = headStyle.fillForegroundColor(); } - styleProperty.setShrinkToFit(headStyle.shrinkToFit().getBooleanValue()); + styleProperty.shrinkToFit = headStyle.shrinkToFit().getBooleanValue(); return styleProperty; } @@ -223,44 +219,44 @@ public static StyleProperty build(ContentStyle contentStyle) { if (contentStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(contentStyle.dataFormat()); - styleProperty.setDataFormatData(dataFormatData); + styleProperty.dataFormatData = dataFormatData; } - styleProperty.setHidden(contentStyle.hidden().getBooleanValue()); - styleProperty.setLocked(contentStyle.locked().getBooleanValue()); - styleProperty.setQuotePrefix(contentStyle.quotePrefix().getBooleanValue()); - styleProperty.setHorizontalAlignment(contentStyle.horizontalAlignment().getPoiHorizontalAlignment()); - styleProperty.setWrapped(contentStyle.wrapped().getBooleanValue()); - styleProperty.setVerticalAlignment(contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); + styleProperty.hidden = contentStyle.hidden().getBooleanValue(); + styleProperty.locked = contentStyle.locked().getBooleanValue(); + styleProperty.quotePrefix = contentStyle.quotePrefix().getBooleanValue(); + styleProperty.horizontalAlignment = contentStyle.horizontalAlignment().getPoiHorizontalAlignment(); + styleProperty.wrapped = contentStyle.wrapped().getBooleanValue(); + styleProperty.verticalAlignment = contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); if (contentStyle.rotation() >= 0) { - styleProperty.setRotation(contentStyle.rotation()); + styleProperty.rotation = contentStyle.rotation(); } if (contentStyle.indent() >= 0) { - styleProperty.setIndent(contentStyle.indent()); + styleProperty.indent = contentStyle.indent(); } - styleProperty.setBorderLeft(contentStyle.borderLeft().getPoiBorderStyle()); - styleProperty.setBorderRight(contentStyle.borderRight().getPoiBorderStyle()); - styleProperty.setBorderTop(contentStyle.borderTop().getPoiBorderStyle()); - styleProperty.setBorderBottom(contentStyle.borderBottom().getPoiBorderStyle()); + styleProperty.borderLeft = contentStyle.borderLeft().getPoiBorderStyle(); + styleProperty.borderRight = contentStyle.borderRight().getPoiBorderStyle(); + styleProperty.borderTop = contentStyle.borderTop().getPoiBorderStyle(); + styleProperty.borderBottom = contentStyle.borderBottom().getPoiBorderStyle(); if (contentStyle.leftBorderColor() >= 0) { - styleProperty.setLeftBorderColor(contentStyle.leftBorderColor()); + styleProperty.leftBorderColor = contentStyle.leftBorderColor(); } if (contentStyle.rightBorderColor() >= 0) { - styleProperty.setRightBorderColor(contentStyle.rightBorderColor()); + styleProperty.rightBorderColor = contentStyle.rightBorderColor(); } if (contentStyle.topBorderColor() >= 0) { - styleProperty.setTopBorderColor(contentStyle.topBorderColor()); + styleProperty.topBorderColor = contentStyle.topBorderColor(); } if (contentStyle.bottomBorderColor() >= 0) { - styleProperty.setBottomBorderColor(contentStyle.bottomBorderColor()); + styleProperty.bottomBorderColor = contentStyle.bottomBorderColor(); } - styleProperty.setFillPatternType(contentStyle.fillPatternType().getPoiFillPatternType()); + styleProperty.fillPatternType = contentStyle.fillPatternType().getPoiFillPatternType(); if (contentStyle.fillBackgroundColor() >= 0) { - styleProperty.setFillBackgroundColor(contentStyle.fillBackgroundColor()); + styleProperty.fillBackgroundColor = contentStyle.fillBackgroundColor(); } if (contentStyle.fillForegroundColor() >= 0) { - styleProperty.setFillForegroundColor(contentStyle.fillForegroundColor()); + styleProperty.fillForegroundColor = contentStyle.fillForegroundColor(); } - styleProperty.setShrinkToFit(contentStyle.shrinkToFit().getBooleanValue()); + styleProperty.shrinkToFit = contentStyle.shrinkToFit().getBooleanValue(); return styleProperty; } } diff --git a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java index 72e702e6b..6183d155c 100644 --- a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java +++ b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java @@ -19,7 +19,6 @@ package org.apache.fesod.sheet.write.style; -import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty; import org.apache.fesod.sheet.testkit.Tags; import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder; import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder; @@ -63,17 +62,6 @@ void constructor_acceptsPositiveValues() { Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 4, 5)); } - @Test - void constructor_fromProperty_shouldNotThrowException() { - SheetFreezePaneProperty property = new SheetFreezePaneProperty(); - property.setColSplit(1); - property.setRowSplit(2); - property.setLeftmostColumn(3); - property.setTopRow(4); - - Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(property)); - } - @Test void afterSheetCreate_createsFreezePaneWithCorrectParams() { SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(2, 3, 4, 5); From 52d48989836f2a3e33094fac0b33438650d48c02 Mon Sep 17 00:00:00 2001 From: Bengbengbalabalabeng Date: Sun, 16 Aug 2026 12:50:49 +0800 Subject: [PATCH 2/4] refactor: add deprecated setters to property classes before making them immutable --- .../property/ColumnWidthProperty.java | 10 +- .../property/DateTimeFormatProperty.java | 20 +- .../sheet/metadata/property/FontProperty.java | 108 ++++++-- .../metadata/property/LoopMergeProperty.java | 20 +- .../property/NumberFormatProperty.java | 20 +- .../property/OnceAbsoluteMergeProperty.java | 40 ++- .../metadata/property/RowHeightProperty.java | 10 +- .../property/SheetFreezePaneProperty.java | 40 ++- .../metadata/property/StyleProperty.java | 260 +++++++++++++++--- .../style/SheetFreezePaneStrategyTest.java | 8 + 10 files changed, 460 insertions(+), 76 deletions(-) diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java index c62483dbc..047654643 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java @@ -37,7 +37,15 @@ @Getter @AllArgsConstructor public class ColumnWidthProperty { - private final Integer width; + private Integer width; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setWidth(Integer width) { + this.width = width; + } public static ColumnWidthProperty build(ColumnWidth columnWidth) { if (columnWidth == null || columnWidth.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java index a9d9f54d1..4e7e89513 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java @@ -38,8 +38,24 @@ @Getter @AllArgsConstructor public class DateTimeFormatProperty { - private final String format; - private final Boolean use1904windowing; + private String format; + private Boolean use1904windowing; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFormat(String format) { + this.format = format; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setUse1904windowing(Boolean use1904windowing) { + this.use1904windowing = use1904windowing; + } public static DateTimeFormatProperty build(DateTimeFormat dateTimeFormat) { if (dateTimeFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java index 7d65bc5c2..ad829e3db 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java @@ -98,32 +98,104 @@ public class FontProperty { */ private Boolean bold; + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFontName(String fontName) { + this.fontName = fontName; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFontHeightInPoints(Short fontHeightInPoints) { + this.fontHeightInPoints = fontHeightInPoints; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setItalic(Boolean italic) { + this.italic = italic; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setStrikeout(Boolean strikeout) { + this.strikeout = strikeout; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setColor(Short color) { + this.color = color; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setTypeOffset(Short typeOffset) { + this.typeOffset = typeOffset; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setUnderline(Byte underline) { + this.underline = underline; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setCharset(Integer charset) { + this.charset = charset; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBold(Boolean bold) { + this.bold = bold; + } + public static FontProperty build(HeadFontStyle headFontStyle) { if (headFontStyle == null) { return null; } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(headFontStyle.fontName())) { - styleProperty.fontName = headFontStyle.fontName(); + styleProperty.setFontName(headFontStyle.fontName()); } if (headFontStyle.fontHeightInPoints() >= 0) { - styleProperty.fontHeightInPoints = headFontStyle.fontHeightInPoints(); + styleProperty.setFontHeightInPoints(headFontStyle.fontHeightInPoints()); } - styleProperty.italic = headFontStyle.italic().getBooleanValue(); - styleProperty.strikeout = headFontStyle.strikeout().getBooleanValue(); + styleProperty.setItalic(headFontStyle.italic().getBooleanValue()); + styleProperty.setStrikeout(headFontStyle.strikeout().getBooleanValue()); if (headFontStyle.color() >= 0) { - styleProperty.color = headFontStyle.color(); + styleProperty.setColor(headFontStyle.color()); } if (headFontStyle.typeOffset() >= 0) { - styleProperty.typeOffset = headFontStyle.typeOffset(); + styleProperty.setTypeOffset(headFontStyle.typeOffset()); } if (headFontStyle.underline() >= 0) { - styleProperty.underline = headFontStyle.underline(); + styleProperty.setUnderline(headFontStyle.underline()); } if (headFontStyle.charset() >= 0) { - styleProperty.charset = headFontStyle.charset(); + styleProperty.setCharset(headFontStyle.charset()); } - styleProperty.bold = headFontStyle.bold().getBooleanValue(); + styleProperty.setBold(headFontStyle.bold().getBooleanValue()); return styleProperty; } @@ -133,26 +205,26 @@ public static FontProperty build(ContentFontStyle contentFontStyle) { } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(contentFontStyle.fontName())) { - styleProperty.fontName = contentFontStyle.fontName(); + styleProperty.setFontName(contentFontStyle.fontName()); } if (contentFontStyle.fontHeightInPoints() >= 0) { - styleProperty.fontHeightInPoints = contentFontStyle.fontHeightInPoints(); + styleProperty.setFontHeightInPoints(contentFontStyle.fontHeightInPoints()); } - styleProperty.italic = contentFontStyle.italic().getBooleanValue(); - styleProperty.strikeout = contentFontStyle.strikeout().getBooleanValue(); + styleProperty.setItalic(contentFontStyle.italic().getBooleanValue()); + styleProperty.setStrikeout(contentFontStyle.strikeout().getBooleanValue()); if (contentFontStyle.color() >= 0) { - styleProperty.color = contentFontStyle.color(); + styleProperty.setColor(contentFontStyle.color()); } if (contentFontStyle.typeOffset() >= 0) { - styleProperty.typeOffset = contentFontStyle.typeOffset(); + styleProperty.setTypeOffset(contentFontStyle.typeOffset()); } if (contentFontStyle.underline() >= 0) { - styleProperty.underline = contentFontStyle.underline(); + styleProperty.setUnderline(contentFontStyle.underline()); } if (contentFontStyle.charset() >= 0) { - styleProperty.charset = contentFontStyle.charset(); + styleProperty.setCharset(contentFontStyle.charset()); } - styleProperty.bold = contentFontStyle.bold().getBooleanValue(); + styleProperty.setBold(contentFontStyle.bold().getBooleanValue()); return styleProperty; } } diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java index a95faa3fb..d6ad8dcd2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java @@ -40,11 +40,27 @@ public class LoopMergeProperty { /** * Each row */ - private final int eachRow; + private int eachRow; /** * Extend column */ - private final int columnExtend; + private int columnExtend; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setEachRow(int eachRow) { + this.eachRow = eachRow; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setColumnExtend(int columnExtend) { + this.columnExtend = columnExtend; + } public static LoopMergeProperty build(ContentLoopMerge contentLoopMerge) { if (contentLoopMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java index a8bbefbfe..2fb98c301 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java @@ -38,8 +38,24 @@ @Getter @AllArgsConstructor public class NumberFormatProperty { - private final String format; - private final RoundingMode roundingMode; + private String format; + private RoundingMode roundingMode; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFormat(String format) { + this.format = format; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setRoundingMode(RoundingMode roundingMode) { + this.roundingMode = roundingMode; + } public static NumberFormatProperty build(NumberFormat numberFormat) { if (numberFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java index 6b9739bd2..e26c92668 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java @@ -40,19 +40,51 @@ public class OnceAbsoluteMergeProperty { /** * First row */ - private final int firstRowIndex; + private int firstRowIndex; /** * Last row */ - private final int lastRowIndex; + private int lastRowIndex; /** * First column */ - private final int firstColumnIndex; + private int firstColumnIndex; /** * Last row */ - private final int lastColumnIndex; + private int lastColumnIndex; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFirstRowIndex(int firstRowIndex) { + this.firstRowIndex = firstRowIndex; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setLastRowIndex(int lastRowIndex) { + this.lastRowIndex = lastRowIndex; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFirstColumnIndex(int firstColumnIndex) { + this.firstColumnIndex = firstColumnIndex; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setLastColumnIndex(int lastColumnIndex) { + this.lastColumnIndex = lastColumnIndex; + } public static OnceAbsoluteMergeProperty build(OnceAbsoluteMerge onceAbsoluteMerge) { if (onceAbsoluteMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java index a2bef41f2..082bb1e32 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java @@ -38,7 +38,15 @@ @Getter @AllArgsConstructor public class RowHeightProperty { - private final Short height; + private Short height; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setHeight(Short height) { + this.height = height; + } public static RowHeightProperty build(HeadRowHeight headRowHeight) { if (headRowHeight == null || headRowHeight.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java index f7f80ece9..1bc0634e1 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java @@ -36,22 +36,54 @@ public class SheetFreezePaneProperty { /** * Horizontal position of split. */ - private final int colSplit; + private int colSplit; /** * Vertical position of split. */ - private final int rowSplit; + private int rowSplit; /** * Left column visible in right pane. */ - private final int leftmostColumn; + private int leftmostColumn; /** * Top row visible in bottom pane */ - private final int topRow; + private int topRow; + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setColSplit(int colSplit) { + this.colSplit = colSplit; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setRowSplit(int rowSplit) { + this.rowSplit = rowSplit; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setLeftmostColumn(int leftmostColumn) { + this.leftmostColumn = leftmostColumn; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setTopRow(int topRow) { + this.topRow = topRow; + } public static SheetFreezePaneProperty build(FreezePane freezePane) { if (freezePane == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java index 5ef8af7e1..d2a56faaa 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java @@ -162,6 +162,182 @@ public class StyleProperty { */ private Boolean shrinkToFit; + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setDataFormatData(DataFormatData dataFormatData) { + this.dataFormatData = dataFormatData; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setWriteFont(WriteFont writeFont) { + this.writeFont = writeFont; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setHidden(Boolean hidden) { + this.hidden = hidden; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setLocked(Boolean locked) { + this.locked = locked; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setQuotePrefix(Boolean quotePrefix) { + this.quotePrefix = quotePrefix; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setWrapped(Boolean wrapped) { + this.wrapped = wrapped; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setVerticalAlignment(VerticalAlignment verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setRotation(Short rotation) { + this.rotation = rotation; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setIndent(Short indent) { + this.indent = indent; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBorderLeft(BorderStyle borderLeft) { + this.borderLeft = borderLeft; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBorderRight(BorderStyle borderRight) { + this.borderRight = borderRight; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBorderTop(BorderStyle borderTop) { + this.borderTop = borderTop; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBorderBottom(BorderStyle borderBottom) { + this.borderBottom = borderBottom; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setLeftBorderColor(Short leftBorderColor) { + this.leftBorderColor = leftBorderColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setRightBorderColor(Short rightBorderColor) { + this.rightBorderColor = rightBorderColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setTopBorderColor(Short topBorderColor) { + this.topBorderColor = topBorderColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setBottomBorderColor(Short bottomBorderColor) { + this.bottomBorderColor = bottomBorderColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFillPatternType(FillPatternType fillPatternType) { + this.fillPatternType = fillPatternType; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFillBackgroundColor(Short fillBackgroundColor) { + this.fillBackgroundColor = fillBackgroundColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setFillForegroundColor(Short fillForegroundColor) { + this.fillForegroundColor = fillForegroundColor; + } + + /** + * @deprecated This setter will be removed in a future release to make the class immutable. + */ + @Deprecated + public void setShrinkToFit(Boolean shrinkToFit) { + this.shrinkToFit = shrinkToFit; + } + public static StyleProperty build(HeadStyle headStyle) { if (headStyle == null) { return null; @@ -170,44 +346,44 @@ public static StyleProperty build(HeadStyle headStyle) { if (headStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(headStyle.dataFormat()); - styleProperty.dataFormatData = dataFormatData; + styleProperty.setDataFormatData(dataFormatData); } - styleProperty.hidden = headStyle.hidden().getBooleanValue(); - styleProperty.locked = headStyle.locked().getBooleanValue(); - styleProperty.quotePrefix = headStyle.quotePrefix().getBooleanValue(); - styleProperty.horizontalAlignment = headStyle.horizontalAlignment().getPoiHorizontalAlignment(); - styleProperty.wrapped = headStyle.wrapped().getBooleanValue(); - styleProperty.verticalAlignment = headStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); + styleProperty.setHidden(headStyle.hidden().getBooleanValue()); + styleProperty.setLocked(headStyle.locked().getBooleanValue()); + styleProperty.setQuotePrefix(headStyle.quotePrefix().getBooleanValue()); + styleProperty.setHorizontalAlignment(headStyle.horizontalAlignment().getPoiHorizontalAlignment()); + styleProperty.setWrapped(headStyle.wrapped().getBooleanValue()); + styleProperty.setVerticalAlignment(headStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); if (headStyle.rotation() >= 0) { - styleProperty.rotation = headStyle.rotation(); + styleProperty.setRotation(headStyle.rotation()); } if (headStyle.indent() >= 0) { - styleProperty.indent = headStyle.indent(); + styleProperty.setIndent(headStyle.indent()); } - styleProperty.borderLeft = headStyle.borderLeft().getPoiBorderStyle(); - styleProperty.borderRight = headStyle.borderRight().getPoiBorderStyle(); - styleProperty.borderTop = headStyle.borderTop().getPoiBorderStyle(); - styleProperty.borderBottom = headStyle.borderBottom().getPoiBorderStyle(); + styleProperty.setBorderLeft(headStyle.borderLeft().getPoiBorderStyle()); + styleProperty.setBorderRight(headStyle.borderRight().getPoiBorderStyle()); + styleProperty.setBorderTop(headStyle.borderTop().getPoiBorderStyle()); + styleProperty.setBorderBottom(headStyle.borderBottom().getPoiBorderStyle()); if (headStyle.leftBorderColor() >= 0) { - styleProperty.leftBorderColor = headStyle.leftBorderColor(); + styleProperty.setLeftBorderColor(headStyle.leftBorderColor()); } if (headStyle.rightBorderColor() >= 0) { - styleProperty.rightBorderColor = headStyle.rightBorderColor(); + styleProperty.setRightBorderColor(headStyle.rightBorderColor()); } if (headStyle.topBorderColor() >= 0) { - styleProperty.topBorderColor = headStyle.topBorderColor(); + styleProperty.setTopBorderColor(headStyle.topBorderColor()); } if (headStyle.bottomBorderColor() >= 0) { - styleProperty.bottomBorderColor = headStyle.bottomBorderColor(); + styleProperty.setBottomBorderColor(headStyle.bottomBorderColor()); } - styleProperty.fillPatternType = headStyle.fillPatternType().getPoiFillPatternType(); + styleProperty.setFillPatternType(headStyle.fillPatternType().getPoiFillPatternType()); if (headStyle.fillBackgroundColor() >= 0) { - styleProperty.fillBackgroundColor = headStyle.fillBackgroundColor(); + styleProperty.setFillBackgroundColor(headStyle.fillBackgroundColor()); } if (headStyle.fillForegroundColor() >= 0) { - styleProperty.fillForegroundColor = headStyle.fillForegroundColor(); + styleProperty.setFillForegroundColor(headStyle.fillForegroundColor()); } - styleProperty.shrinkToFit = headStyle.shrinkToFit().getBooleanValue(); + styleProperty.setShrinkToFit(headStyle.shrinkToFit().getBooleanValue()); return styleProperty; } @@ -219,44 +395,44 @@ public static StyleProperty build(ContentStyle contentStyle) { if (contentStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(contentStyle.dataFormat()); - styleProperty.dataFormatData = dataFormatData; + styleProperty.setDataFormatData(dataFormatData); } - styleProperty.hidden = contentStyle.hidden().getBooleanValue(); - styleProperty.locked = contentStyle.locked().getBooleanValue(); - styleProperty.quotePrefix = contentStyle.quotePrefix().getBooleanValue(); - styleProperty.horizontalAlignment = contentStyle.horizontalAlignment().getPoiHorizontalAlignment(); - styleProperty.wrapped = contentStyle.wrapped().getBooleanValue(); - styleProperty.verticalAlignment = contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); + styleProperty.setHidden(contentStyle.hidden().getBooleanValue()); + styleProperty.setLocked(contentStyle.locked().getBooleanValue()); + styleProperty.setQuotePrefix(contentStyle.quotePrefix().getBooleanValue()); + styleProperty.setHorizontalAlignment(contentStyle.horizontalAlignment().getPoiHorizontalAlignment()); + styleProperty.setWrapped(contentStyle.wrapped().getBooleanValue()); + styleProperty.setVerticalAlignment(contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); if (contentStyle.rotation() >= 0) { - styleProperty.rotation = contentStyle.rotation(); + styleProperty.setRotation(contentStyle.rotation()); } if (contentStyle.indent() >= 0) { - styleProperty.indent = contentStyle.indent(); + styleProperty.setIndent(contentStyle.indent()); } - styleProperty.borderLeft = contentStyle.borderLeft().getPoiBorderStyle(); - styleProperty.borderRight = contentStyle.borderRight().getPoiBorderStyle(); - styleProperty.borderTop = contentStyle.borderTop().getPoiBorderStyle(); - styleProperty.borderBottom = contentStyle.borderBottom().getPoiBorderStyle(); + styleProperty.setBorderLeft(contentStyle.borderLeft().getPoiBorderStyle()); + styleProperty.setBorderRight(contentStyle.borderRight().getPoiBorderStyle()); + styleProperty.setBorderTop(contentStyle.borderTop().getPoiBorderStyle()); + styleProperty.setBorderBottom(contentStyle.borderBottom().getPoiBorderStyle()); if (contentStyle.leftBorderColor() >= 0) { - styleProperty.leftBorderColor = contentStyle.leftBorderColor(); + styleProperty.setLeftBorderColor(contentStyle.leftBorderColor()); } if (contentStyle.rightBorderColor() >= 0) { - styleProperty.rightBorderColor = contentStyle.rightBorderColor(); + styleProperty.setRightBorderColor(contentStyle.rightBorderColor()); } if (contentStyle.topBorderColor() >= 0) { - styleProperty.topBorderColor = contentStyle.topBorderColor(); + styleProperty.setTopBorderColor(contentStyle.topBorderColor()); } if (contentStyle.bottomBorderColor() >= 0) { - styleProperty.bottomBorderColor = contentStyle.bottomBorderColor(); + styleProperty.setBottomBorderColor(contentStyle.bottomBorderColor()); } - styleProperty.fillPatternType = contentStyle.fillPatternType().getPoiFillPatternType(); + styleProperty.setFillPatternType(contentStyle.fillPatternType().getPoiFillPatternType()); if (contentStyle.fillBackgroundColor() >= 0) { - styleProperty.fillBackgroundColor = contentStyle.fillBackgroundColor(); + styleProperty.setFillBackgroundColor(contentStyle.fillBackgroundColor()); } if (contentStyle.fillForegroundColor() >= 0) { - styleProperty.fillForegroundColor = contentStyle.fillForegroundColor(); + styleProperty.setFillForegroundColor(contentStyle.fillForegroundColor()); } - styleProperty.shrinkToFit = contentStyle.shrinkToFit().getBooleanValue(); + styleProperty.setShrinkToFit(contentStyle.shrinkToFit().getBooleanValue()); return styleProperty; } } diff --git a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java index 6183d155c..d7421fd52 100644 --- a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java +++ b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java @@ -19,6 +19,7 @@ package org.apache.fesod.sheet.write.style; +import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty; import org.apache.fesod.sheet.testkit.Tags; import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder; import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder; @@ -62,6 +63,13 @@ void constructor_acceptsPositiveValues() { Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 4, 5)); } + @Test + void constructor_fromProperty_shouldNotThrowException() { + SheetFreezePaneProperty property = new SheetFreezePaneProperty(2, 3, 4, 5); + + Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(property)); + } + @Test void afterSheetCreate_createsFreezePaneWithCorrectParams() { SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(2, 3, 4, 5); From 3da2285af72d22fdb85b886f21e8e77db3830d0c Mon Sep 17 00:00:00 2001 From: Bengbengbalabalabeng Date: Sun, 16 Aug 2026 18:55:01 +0800 Subject: [PATCH 3/4] Revert "refactor: add deprecated setters to property classes before making them immutable" This reverts commit 52d48989836f2a3e33094fac0b33438650d48c02. --- .../property/ColumnWidthProperty.java | 10 +- .../property/DateTimeFormatProperty.java | 20 +- .../sheet/metadata/property/FontProperty.java | 108 ++------ .../metadata/property/LoopMergeProperty.java | 20 +- .../property/NumberFormatProperty.java | 20 +- .../property/OnceAbsoluteMergeProperty.java | 40 +-- .../metadata/property/RowHeightProperty.java | 10 +- .../property/SheetFreezePaneProperty.java | 40 +-- .../metadata/property/StyleProperty.java | 260 +++--------------- .../style/SheetFreezePaneStrategyTest.java | 8 - 10 files changed, 76 insertions(+), 460 deletions(-) diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java index 047654643..c62483dbc 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/ColumnWidthProperty.java @@ -37,15 +37,7 @@ @Getter @AllArgsConstructor public class ColumnWidthProperty { - private Integer width; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setWidth(Integer width) { - this.width = width; - } + private final Integer width; public static ColumnWidthProperty build(ColumnWidth columnWidth) { if (columnWidth == null || columnWidth.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java index 4e7e89513..a9d9f54d1 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java @@ -38,24 +38,8 @@ @Getter @AllArgsConstructor public class DateTimeFormatProperty { - private String format; - private Boolean use1904windowing; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFormat(String format) { - this.format = format; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setUse1904windowing(Boolean use1904windowing) { - this.use1904windowing = use1904windowing; - } + private final String format; + private final Boolean use1904windowing; public static DateTimeFormatProperty build(DateTimeFormat dateTimeFormat) { if (dateTimeFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java index ad829e3db..7d65bc5c2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/FontProperty.java @@ -98,104 +98,32 @@ public class FontProperty { */ private Boolean bold; - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFontName(String fontName) { - this.fontName = fontName; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFontHeightInPoints(Short fontHeightInPoints) { - this.fontHeightInPoints = fontHeightInPoints; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setItalic(Boolean italic) { - this.italic = italic; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setStrikeout(Boolean strikeout) { - this.strikeout = strikeout; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setColor(Short color) { - this.color = color; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setTypeOffset(Short typeOffset) { - this.typeOffset = typeOffset; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setUnderline(Byte underline) { - this.underline = underline; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setCharset(Integer charset) { - this.charset = charset; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBold(Boolean bold) { - this.bold = bold; - } - public static FontProperty build(HeadFontStyle headFontStyle) { if (headFontStyle == null) { return null; } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(headFontStyle.fontName())) { - styleProperty.setFontName(headFontStyle.fontName()); + styleProperty.fontName = headFontStyle.fontName(); } if (headFontStyle.fontHeightInPoints() >= 0) { - styleProperty.setFontHeightInPoints(headFontStyle.fontHeightInPoints()); + styleProperty.fontHeightInPoints = headFontStyle.fontHeightInPoints(); } - styleProperty.setItalic(headFontStyle.italic().getBooleanValue()); - styleProperty.setStrikeout(headFontStyle.strikeout().getBooleanValue()); + styleProperty.italic = headFontStyle.italic().getBooleanValue(); + styleProperty.strikeout = headFontStyle.strikeout().getBooleanValue(); if (headFontStyle.color() >= 0) { - styleProperty.setColor(headFontStyle.color()); + styleProperty.color = headFontStyle.color(); } if (headFontStyle.typeOffset() >= 0) { - styleProperty.setTypeOffset(headFontStyle.typeOffset()); + styleProperty.typeOffset = headFontStyle.typeOffset(); } if (headFontStyle.underline() >= 0) { - styleProperty.setUnderline(headFontStyle.underline()); + styleProperty.underline = headFontStyle.underline(); } if (headFontStyle.charset() >= 0) { - styleProperty.setCharset(headFontStyle.charset()); + styleProperty.charset = headFontStyle.charset(); } - styleProperty.setBold(headFontStyle.bold().getBooleanValue()); + styleProperty.bold = headFontStyle.bold().getBooleanValue(); return styleProperty; } @@ -205,26 +133,26 @@ public static FontProperty build(ContentFontStyle contentFontStyle) { } FontProperty styleProperty = new FontProperty(); if (StringUtils.isNotBlank(contentFontStyle.fontName())) { - styleProperty.setFontName(contentFontStyle.fontName()); + styleProperty.fontName = contentFontStyle.fontName(); } if (contentFontStyle.fontHeightInPoints() >= 0) { - styleProperty.setFontHeightInPoints(contentFontStyle.fontHeightInPoints()); + styleProperty.fontHeightInPoints = contentFontStyle.fontHeightInPoints(); } - styleProperty.setItalic(contentFontStyle.italic().getBooleanValue()); - styleProperty.setStrikeout(contentFontStyle.strikeout().getBooleanValue()); + styleProperty.italic = contentFontStyle.italic().getBooleanValue(); + styleProperty.strikeout = contentFontStyle.strikeout().getBooleanValue(); if (contentFontStyle.color() >= 0) { - styleProperty.setColor(contentFontStyle.color()); + styleProperty.color = contentFontStyle.color(); } if (contentFontStyle.typeOffset() >= 0) { - styleProperty.setTypeOffset(contentFontStyle.typeOffset()); + styleProperty.typeOffset = contentFontStyle.typeOffset(); } if (contentFontStyle.underline() >= 0) { - styleProperty.setUnderline(contentFontStyle.underline()); + styleProperty.underline = contentFontStyle.underline(); } if (contentFontStyle.charset() >= 0) { - styleProperty.setCharset(contentFontStyle.charset()); + styleProperty.charset = contentFontStyle.charset(); } - styleProperty.setBold(contentFontStyle.bold().getBooleanValue()); + styleProperty.bold = contentFontStyle.bold().getBooleanValue(); return styleProperty; } } diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java index d6ad8dcd2..a95faa3fb 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/LoopMergeProperty.java @@ -40,27 +40,11 @@ public class LoopMergeProperty { /** * Each row */ - private int eachRow; + private final int eachRow; /** * Extend column */ - private int columnExtend; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setEachRow(int eachRow) { - this.eachRow = eachRow; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setColumnExtend(int columnExtend) { - this.columnExtend = columnExtend; - } + private final int columnExtend; public static LoopMergeProperty build(ContentLoopMerge contentLoopMerge) { if (contentLoopMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java index 2fb98c301..a8bbefbfe 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/NumberFormatProperty.java @@ -38,24 +38,8 @@ @Getter @AllArgsConstructor public class NumberFormatProperty { - private String format; - private RoundingMode roundingMode; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFormat(String format) { - this.format = format; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setRoundingMode(RoundingMode roundingMode) { - this.roundingMode = roundingMode; - } + private final String format; + private final RoundingMode roundingMode; public static NumberFormatProperty build(NumberFormat numberFormat) { if (numberFormat == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java index e26c92668..6b9739bd2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/OnceAbsoluteMergeProperty.java @@ -40,51 +40,19 @@ public class OnceAbsoluteMergeProperty { /** * First row */ - private int firstRowIndex; + private final int firstRowIndex; /** * Last row */ - private int lastRowIndex; + private final int lastRowIndex; /** * First column */ - private int firstColumnIndex; + private final int firstColumnIndex; /** * Last row */ - private int lastColumnIndex; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFirstRowIndex(int firstRowIndex) { - this.firstRowIndex = firstRowIndex; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setLastRowIndex(int lastRowIndex) { - this.lastRowIndex = lastRowIndex; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFirstColumnIndex(int firstColumnIndex) { - this.firstColumnIndex = firstColumnIndex; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setLastColumnIndex(int lastColumnIndex) { - this.lastColumnIndex = lastColumnIndex; - } + private final int lastColumnIndex; public static OnceAbsoluteMergeProperty build(OnceAbsoluteMerge onceAbsoluteMerge) { if (onceAbsoluteMerge == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java index 082bb1e32..a2bef41f2 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/RowHeightProperty.java @@ -38,15 +38,7 @@ @Getter @AllArgsConstructor public class RowHeightProperty { - private Short height; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setHeight(Short height) { - this.height = height; - } + private final Short height; public static RowHeightProperty build(HeadRowHeight headRowHeight) { if (headRowHeight == null || headRowHeight.value() < 0) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java index 1bc0634e1..f7f80ece9 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java @@ -36,54 +36,22 @@ public class SheetFreezePaneProperty { /** * Horizontal position of split. */ - private int colSplit; + private final int colSplit; /** * Vertical position of split. */ - private int rowSplit; + private final int rowSplit; /** * Left column visible in right pane. */ - private int leftmostColumn; + private final int leftmostColumn; /** * Top row visible in bottom pane */ - private int topRow; - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setColSplit(int colSplit) { - this.colSplit = colSplit; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setRowSplit(int rowSplit) { - this.rowSplit = rowSplit; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setLeftmostColumn(int leftmostColumn) { - this.leftmostColumn = leftmostColumn; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setTopRow(int topRow) { - this.topRow = topRow; - } + private final int topRow; public static SheetFreezePaneProperty build(FreezePane freezePane) { if (freezePane == null) { diff --git a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java index d2a56faaa..5ef8af7e1 100644 --- a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java +++ b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/StyleProperty.java @@ -162,182 +162,6 @@ public class StyleProperty { */ private Boolean shrinkToFit; - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setDataFormatData(DataFormatData dataFormatData) { - this.dataFormatData = dataFormatData; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setWriteFont(WriteFont writeFont) { - this.writeFont = writeFont; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setHidden(Boolean hidden) { - this.hidden = hidden; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setLocked(Boolean locked) { - this.locked = locked; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setQuotePrefix(Boolean quotePrefix) { - this.quotePrefix = quotePrefix; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { - this.horizontalAlignment = horizontalAlignment; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setWrapped(Boolean wrapped) { - this.wrapped = wrapped; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setVerticalAlignment(VerticalAlignment verticalAlignment) { - this.verticalAlignment = verticalAlignment; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setRotation(Short rotation) { - this.rotation = rotation; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setIndent(Short indent) { - this.indent = indent; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBorderLeft(BorderStyle borderLeft) { - this.borderLeft = borderLeft; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBorderRight(BorderStyle borderRight) { - this.borderRight = borderRight; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBorderTop(BorderStyle borderTop) { - this.borderTop = borderTop; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBorderBottom(BorderStyle borderBottom) { - this.borderBottom = borderBottom; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setLeftBorderColor(Short leftBorderColor) { - this.leftBorderColor = leftBorderColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setRightBorderColor(Short rightBorderColor) { - this.rightBorderColor = rightBorderColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setTopBorderColor(Short topBorderColor) { - this.topBorderColor = topBorderColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setBottomBorderColor(Short bottomBorderColor) { - this.bottomBorderColor = bottomBorderColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFillPatternType(FillPatternType fillPatternType) { - this.fillPatternType = fillPatternType; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFillBackgroundColor(Short fillBackgroundColor) { - this.fillBackgroundColor = fillBackgroundColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setFillForegroundColor(Short fillForegroundColor) { - this.fillForegroundColor = fillForegroundColor; - } - - /** - * @deprecated This setter will be removed in a future release to make the class immutable. - */ - @Deprecated - public void setShrinkToFit(Boolean shrinkToFit) { - this.shrinkToFit = shrinkToFit; - } - public static StyleProperty build(HeadStyle headStyle) { if (headStyle == null) { return null; @@ -346,44 +170,44 @@ public static StyleProperty build(HeadStyle headStyle) { if (headStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(headStyle.dataFormat()); - styleProperty.setDataFormatData(dataFormatData); + styleProperty.dataFormatData = dataFormatData; } - styleProperty.setHidden(headStyle.hidden().getBooleanValue()); - styleProperty.setLocked(headStyle.locked().getBooleanValue()); - styleProperty.setQuotePrefix(headStyle.quotePrefix().getBooleanValue()); - styleProperty.setHorizontalAlignment(headStyle.horizontalAlignment().getPoiHorizontalAlignment()); - styleProperty.setWrapped(headStyle.wrapped().getBooleanValue()); - styleProperty.setVerticalAlignment(headStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); + styleProperty.hidden = headStyle.hidden().getBooleanValue(); + styleProperty.locked = headStyle.locked().getBooleanValue(); + styleProperty.quotePrefix = headStyle.quotePrefix().getBooleanValue(); + styleProperty.horizontalAlignment = headStyle.horizontalAlignment().getPoiHorizontalAlignment(); + styleProperty.wrapped = headStyle.wrapped().getBooleanValue(); + styleProperty.verticalAlignment = headStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); if (headStyle.rotation() >= 0) { - styleProperty.setRotation(headStyle.rotation()); + styleProperty.rotation = headStyle.rotation(); } if (headStyle.indent() >= 0) { - styleProperty.setIndent(headStyle.indent()); + styleProperty.indent = headStyle.indent(); } - styleProperty.setBorderLeft(headStyle.borderLeft().getPoiBorderStyle()); - styleProperty.setBorderRight(headStyle.borderRight().getPoiBorderStyle()); - styleProperty.setBorderTop(headStyle.borderTop().getPoiBorderStyle()); - styleProperty.setBorderBottom(headStyle.borderBottom().getPoiBorderStyle()); + styleProperty.borderLeft = headStyle.borderLeft().getPoiBorderStyle(); + styleProperty.borderRight = headStyle.borderRight().getPoiBorderStyle(); + styleProperty.borderTop = headStyle.borderTop().getPoiBorderStyle(); + styleProperty.borderBottom = headStyle.borderBottom().getPoiBorderStyle(); if (headStyle.leftBorderColor() >= 0) { - styleProperty.setLeftBorderColor(headStyle.leftBorderColor()); + styleProperty.leftBorderColor = headStyle.leftBorderColor(); } if (headStyle.rightBorderColor() >= 0) { - styleProperty.setRightBorderColor(headStyle.rightBorderColor()); + styleProperty.rightBorderColor = headStyle.rightBorderColor(); } if (headStyle.topBorderColor() >= 0) { - styleProperty.setTopBorderColor(headStyle.topBorderColor()); + styleProperty.topBorderColor = headStyle.topBorderColor(); } if (headStyle.bottomBorderColor() >= 0) { - styleProperty.setBottomBorderColor(headStyle.bottomBorderColor()); + styleProperty.bottomBorderColor = headStyle.bottomBorderColor(); } - styleProperty.setFillPatternType(headStyle.fillPatternType().getPoiFillPatternType()); + styleProperty.fillPatternType = headStyle.fillPatternType().getPoiFillPatternType(); if (headStyle.fillBackgroundColor() >= 0) { - styleProperty.setFillBackgroundColor(headStyle.fillBackgroundColor()); + styleProperty.fillBackgroundColor = headStyle.fillBackgroundColor(); } if (headStyle.fillForegroundColor() >= 0) { - styleProperty.setFillForegroundColor(headStyle.fillForegroundColor()); + styleProperty.fillForegroundColor = headStyle.fillForegroundColor(); } - styleProperty.setShrinkToFit(headStyle.shrinkToFit().getBooleanValue()); + styleProperty.shrinkToFit = headStyle.shrinkToFit().getBooleanValue(); return styleProperty; } @@ -395,44 +219,44 @@ public static StyleProperty build(ContentStyle contentStyle) { if (contentStyle.dataFormat() >= 0) { DataFormatData dataFormatData = new DataFormatData(); dataFormatData.setIndex(contentStyle.dataFormat()); - styleProperty.setDataFormatData(dataFormatData); + styleProperty.dataFormatData = dataFormatData; } - styleProperty.setHidden(contentStyle.hidden().getBooleanValue()); - styleProperty.setLocked(contentStyle.locked().getBooleanValue()); - styleProperty.setQuotePrefix(contentStyle.quotePrefix().getBooleanValue()); - styleProperty.setHorizontalAlignment(contentStyle.horizontalAlignment().getPoiHorizontalAlignment()); - styleProperty.setWrapped(contentStyle.wrapped().getBooleanValue()); - styleProperty.setVerticalAlignment(contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum()); + styleProperty.hidden = contentStyle.hidden().getBooleanValue(); + styleProperty.locked = contentStyle.locked().getBooleanValue(); + styleProperty.quotePrefix = contentStyle.quotePrefix().getBooleanValue(); + styleProperty.horizontalAlignment = contentStyle.horizontalAlignment().getPoiHorizontalAlignment(); + styleProperty.wrapped = contentStyle.wrapped().getBooleanValue(); + styleProperty.verticalAlignment = contentStyle.verticalAlignment().getPoiVerticalAlignmentEnum(); if (contentStyle.rotation() >= 0) { - styleProperty.setRotation(contentStyle.rotation()); + styleProperty.rotation = contentStyle.rotation(); } if (contentStyle.indent() >= 0) { - styleProperty.setIndent(contentStyle.indent()); + styleProperty.indent = contentStyle.indent(); } - styleProperty.setBorderLeft(contentStyle.borderLeft().getPoiBorderStyle()); - styleProperty.setBorderRight(contentStyle.borderRight().getPoiBorderStyle()); - styleProperty.setBorderTop(contentStyle.borderTop().getPoiBorderStyle()); - styleProperty.setBorderBottom(contentStyle.borderBottom().getPoiBorderStyle()); + styleProperty.borderLeft = contentStyle.borderLeft().getPoiBorderStyle(); + styleProperty.borderRight = contentStyle.borderRight().getPoiBorderStyle(); + styleProperty.borderTop = contentStyle.borderTop().getPoiBorderStyle(); + styleProperty.borderBottom = contentStyle.borderBottom().getPoiBorderStyle(); if (contentStyle.leftBorderColor() >= 0) { - styleProperty.setLeftBorderColor(contentStyle.leftBorderColor()); + styleProperty.leftBorderColor = contentStyle.leftBorderColor(); } if (contentStyle.rightBorderColor() >= 0) { - styleProperty.setRightBorderColor(contentStyle.rightBorderColor()); + styleProperty.rightBorderColor = contentStyle.rightBorderColor(); } if (contentStyle.topBorderColor() >= 0) { - styleProperty.setTopBorderColor(contentStyle.topBorderColor()); + styleProperty.topBorderColor = contentStyle.topBorderColor(); } if (contentStyle.bottomBorderColor() >= 0) { - styleProperty.setBottomBorderColor(contentStyle.bottomBorderColor()); + styleProperty.bottomBorderColor = contentStyle.bottomBorderColor(); } - styleProperty.setFillPatternType(contentStyle.fillPatternType().getPoiFillPatternType()); + styleProperty.fillPatternType = contentStyle.fillPatternType().getPoiFillPatternType(); if (contentStyle.fillBackgroundColor() >= 0) { - styleProperty.setFillBackgroundColor(contentStyle.fillBackgroundColor()); + styleProperty.fillBackgroundColor = contentStyle.fillBackgroundColor(); } if (contentStyle.fillForegroundColor() >= 0) { - styleProperty.setFillForegroundColor(contentStyle.fillForegroundColor()); + styleProperty.fillForegroundColor = contentStyle.fillForegroundColor(); } - styleProperty.setShrinkToFit(contentStyle.shrinkToFit().getBooleanValue()); + styleProperty.shrinkToFit = contentStyle.shrinkToFit().getBooleanValue(); return styleProperty; } } diff --git a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java index d7421fd52..6183d155c 100644 --- a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java +++ b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java @@ -19,7 +19,6 @@ package org.apache.fesod.sheet.write.style; -import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty; import org.apache.fesod.sheet.testkit.Tags; import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder; import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder; @@ -63,13 +62,6 @@ void constructor_acceptsPositiveValues() { Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 4, 5)); } - @Test - void constructor_fromProperty_shouldNotThrowException() { - SheetFreezePaneProperty property = new SheetFreezePaneProperty(2, 3, 4, 5); - - Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(property)); - } - @Test void afterSheetCreate_createsFreezePaneWithCorrectParams() { SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(2, 3, 4, 5); From 43ae0279b71bff7f9b9a929b21e199082edb3cc2 Mon Sep 17 00:00:00 2001 From: Bengbengbalabalabeng Date: Sun, 16 Aug 2026 18:58:07 +0800 Subject: [PATCH 4/4] refactor: add relevant tests --- .../sheet/write/style/SheetFreezePaneStrategyTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java index 6183d155c..d7421fd52 100644 --- a/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java +++ b/fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java @@ -19,6 +19,7 @@ package org.apache.fesod.sheet.write.style; +import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty; import org.apache.fesod.sheet.testkit.Tags; import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder; import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder; @@ -62,6 +63,13 @@ void constructor_acceptsPositiveValues() { Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 4, 5)); } + @Test + void constructor_fromProperty_shouldNotThrowException() { + SheetFreezePaneProperty property = new SheetFreezePaneProperty(2, 3, 4, 5); + + Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(property)); + } + @Test void afterSheetCreate_createsFreezePaneWithCorrectParams() { SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(2, 3, 4, 5);