Skip to content

Commit fc34d4f

Browse files
awalter17imagejan
authored andcommitted
Modify table API to allow GenericTable to store multiple column types
1 parent 21ce0f7 commit fc34d4f

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/main/java/net/imagej/table/DefaultColumn.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,29 @@
3131

3232
package net.imagej.table;
3333

34-
import org.scijava.util.SizableArrayList;
34+
import org.scijava.util.ObjectArray;
3535

3636
/**
3737
* Default implementation of {@link Column}.
3838
*
3939
* @author Curtis Rueden
4040
* @param <T> The type of data stored in the table.
4141
*/
42-
public class DefaultColumn<T> extends SizableArrayList<T> implements Column<T> {
42+
public class DefaultColumn<T> extends ObjectArray<T> implements Column<T> {
4343

4444
/** The type of this column. */
45-
private Class<T> type;
45+
private final Class<T> type;
4646

4747
/** The column header. */
4848
private String header;
4949

50-
public DefaultColumn() {}
50+
public DefaultColumn(final Class<T> type) {
51+
super(type);
52+
this.type = type;
53+
}
5154

5255
public DefaultColumn(final Class<T> type, final String header) {
56+
super(type);
5357
this.type = type;
5458
this.header = header;
5559
}

src/main/java/net/imagej/table/DefaultGenericTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
*
3737
* @author Curtis Rueden
3838
*/
39-
public class DefaultGenericTable extends AbstractTable<GenericColumn, Object>
40-
implements GenericTable
39+
public class DefaultGenericTable extends
40+
AbstractTable<Column<? extends Object>, Object> implements GenericTable
4141
{
4242

4343
/** Creates an empty table. */

src/main/java/net/imagej/table/GenericColumn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public class GenericColumn extends DefaultColumn<Object> {
4040

4141
public GenericColumn() {
42-
super();
42+
super(Object.class);
4343
}
4444

4545
public GenericColumn(final String header) {

src/main/java/net/imagej/table/GenericTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
*
3737
* @author Curtis Rueden
3838
*/
39-
public interface GenericTable extends Table<GenericColumn, Object> {
39+
public interface GenericTable extends Table<Column<? extends Object>, Object> {
4040
// NB: No implementation needed.
4141
}

0 commit comments

Comments
 (0)