Skip to content

Commit c6e396d

Browse files
committed
Add ability to copy a row
1 parent 94fe2be commit c6e396d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/widen/tabitha/Row.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
public class Row implements Iterable<Row.Cell> {
1212
private final Row.Cell[] cells;
1313

14+
/**
15+
* Create a copy of a row.
16+
* <p>
17+
* This is not a deep copy, as a deep copy is not necessary. Since cells are immutable, columns and values can be
18+
* reused without copying. Setting a new value will lazily create a new cell instance.
19+
*
20+
* @param row The row to copy.
21+
* @return A copy of the row.
22+
*/
23+
public static Row copyOf(Row row)
24+
{
25+
return new Row(Arrays.copyOf(row.cells, row.cells.length));
26+
}
27+
1428
/**
1529
* Create a new row that merges the columns and values of all the given rows.
1630
*

0 commit comments

Comments
 (0)