package jcconf.groovy.swing;

import java.util.Objects;
import java.util.function.Function;

import javax.swing.table.AbstractTableModel;

public class RowFunctionTableModel extends AbstractTableModel {

	private Object[] data;
	private Function<Object, Object[]> rowFunction;

	private Object[][] results;

	public RowFunctionTableModel(Object[] data, Function<Object, Object[]> rowFunction) {
		this.data = data;
		this.rowFunction = rowFunction;
		this.results = new Object[data.length][];
	}

	public Object[] getRowValues(int row) {
		if (results[row] == null) {
			try {
				results[row] = rowFunction.apply(data[row]);
			} catch (Exception e) {
				results[row] = new Object[] { e };
			}
		}
		return results[row];
	}

	@Override
	public int getRowCount() {
		return results.length;
	}

	@Override
	public int getColumnCount() {
		return getRowCount() > 0 ? getRowValues(0).length : 0;
	}

	@Override
	public Object getValueAt(int row, int column) {
		try {
			return Objects.toString(getRowValues(row)[column]);
		} catch (Exception e) {
			return e;
		}
	}

	@Override
	public Class<?> getColumnClass(int column) {
		return getValueAt(0, column).getClass();
	}

}

@@ -27,34 +27,8 @@
 g;%0A%0A
-import java.util.Objects;%0A
 impo
@@ -948,25 +948,8 @@
 urn 
-Objects.toString(
 getR
@@ -969,17 +969,16 @@
 %5Bcolumn%5D
-)
 ;%0A%09%09%7D ca
@@ -1022,110 +1022,6 @@
 %09%7D%0A%0A
-%09@Override%0A%09public Class%3C?%3E getColumnClass(int column) %7B%0A%09%09return getValueAt(0, column).getClass();%0A%09%7D%0A%0A
 %7D%0A

Remove unused code