File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -395,13 +395,18 @@ public void addColumn(String colName, Vector col) {
395395
396396 @ Override
397397 public void replaceColumn (String colName , Vector col ) {
398- if (colNames .contains (colName )) {
399- int index = colNames .indexOf (colName );
400- columns .set (index , col );
401- } else {
402- colNames .add (colName );
403- columns .add (col );
404- colNamesIndex .put (colName , colNamesIndex .size ());
405- }
398+ if (Objects .isNull (colName ) || Objects .isNull (col ))
399+ throw new RuntimeException ("The param 'colName' or 'col' in table cannot be null." );
400+
401+ if (!colNames .contains (colName ))
402+ throw new RuntimeException ("The column '" + colName + "' to be replaced doesn't exist in the table." );
403+
404+ if (this .colRows != 0 && col .rows () != this .colRows )
405+ throw new RuntimeException ("The length of column " + colName + " must be the same as the first column length: " + this .colRows +"." );
406+
407+ colNames .add (colName );
408+ colNamesIndex .put (colName , colNamesIndex .size ());
409+ columns .add (col );
410+ this .colRows = col .rows ();
406411 }
407412}
You can’t perform that action at this time.
0 commit comments