import org.apache.poi.util.Beta;
@Beta
-public class CellCopyPolicy implements Cloneable {
+public class CellCopyPolicy {
// cell-level policies
public static final boolean DEFAULT_COPY_CELL_VALUE_POLICY = true;
public static final boolean DEFAULT_COPY_CELL_STYLE_POLICY = true;
*/
public CellCopyPolicy() { }
+ /**
+ * Copy constructor
+ *
+ * @param other policy to copy
+ */
+ public CellCopyPolicy(CellCopyPolicy other) {
+ copyCellValue = other.isCopyCellValue();
+ copyCellStyle = other.isCopyCellStyle();
+ copyCellFormula = other.isCopyCellFormula();
+ copyHyperlink = other.isCopyHyperlink();
+ mergeHyperlink = other.isMergeHyperlink();
+
+ copyRowHeight = other.isCopyRowHeight();
+ condenseRows = other.isCondenseRows();
+
+ copyMergedRegions = other.isCopyMergedRegions();
+ }
+
// should builder be replaced with CellCopyPolicy setters that return the object
// to allow setters to be chained together?
// policy.setCopyCellValue(true).setCopyCellStyle(true)
}
}
- private Builder createBuilder() {
+ public Builder createBuilder() {
final Builder builder = new Builder()
.cellValue(copyCellValue)
.cellStyle(copyCellStyle)
.mergedRegions(copyMergedRegions);
return builder;
}
-
- @Override
- public CellCopyPolicy clone() {
- return createBuilder().build();
- }
/*
* Cell-level policies
// FIXME: is special behavior needed if srcRows and destRows belong to the same sheets and the regions overlap?
- final CellCopyPolicy options = policy.clone();
+ final CellCopyPolicy options = new CellCopyPolicy(policy);
// avoid O(N^2) performance scanning through all regions for each row
// merged regions will be copied after all the rows have been copied
options.setCopyMergedRegions(false);