package com.onaro.sanscreen.client.view.tabular; import org.eclipse.core.runtime.IAdaptable; import com.onaro.client.swing.table.functional.IFunction; import com.onaro.client.swing.table.functional.IFunctionGroup; import com.onaro.sanscreen.client.view.tabular.columns.ColumnBuilder; import com.onaro.util.jfc.tables.FilterTable; import com.onaro.util.jfc.tables.filter.Filter; /** * A simple column that evaluates the specified function to retrieve the value for the input row. * * @param the type returned by the function, and the column value type. * @param the function interface type used by the column * * @see IFunction * @deprecated Use {@link ColumnBuilder} instead */ public class FunctionalColumn> extends AdaptableTabularColumn { private static final long serialVersionUID = 1L; private final Class functionInterface; /** * Construct a Functional Column * @param functionInterface the IFunction used to evaluate the rows for the value of the column. * @param outputClass the output type returned by the IFunction * @param id identifier of the column * @param name display name of the column */ public FunctionalColumn(Class functionInterface, Class outputClass, String id, String name) { super(id, outputClass, name); if (functionInterface == null) throw new IllegalArgumentException("functionInterface"); //$NON-NLS-1$ this.functionInterface = functionInterface; Filter filter = FilterTable.DEFAULT_FILTER_FACTORY.create(outputClass); setFilter(filter); } @Override public Output getValue(IAdaptable rowObj) throws Exception { F function = getRequiredFunction(functionInterface); Output result = function.evaluate(rowObj); return result; } @Override public void getRequiredFunctions(IFunctionGroup functionGroup) { super.getRequiredFunctions(functionGroup); functionGroup.add(functionInterface); } }