Skip to content

Commit

Permalink
Add ability to copy a row
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Jun 7, 2017
1 parent 94fe2be commit c6e396d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/widen/tabitha/Row.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
public class Row implements Iterable<Row.Cell> {
private final Row.Cell[] cells;

/**
* Create a copy of a row.
* <p>
* This is not a deep copy, as a deep copy is not necessary. Since cells are immutable, columns and values can be
* reused without copying. Setting a new value will lazily create a new cell instance.
*
* @param row The row to copy.
* @return A copy of the row.
*/
public static Row copyOf(Row row)
{
return new Row(Arrays.copyOf(row.cells, row.cells.length));
}

/**
* Create a new row that merges the columns and values of all the given rows.
*
Expand Down

0 comments on commit c6e396d

Please sign in to comment.