package com.onaro.sanscreen.client.view.tabular; import org.apache.commons.lang3.StringUtils; 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; /** * Table column that retrieves its value from a property on a Function's return value. * For example, a Function could take a Host as input, return an Application, then a property * could be read from that Application. * * @param Input data type that is used by the Function * @param Ouput data type that is returned by the Function * @param The Function interface used by this column * * @deprecated Use {@link ColumnBuilder} instead */ public class FunctionalPropertyColumn2> extends FunctionalPropertyColumn { private static final long serialVersionUID = 1L; private Class functionClass; /** * Construct a FunctionalPropertyColumn2 column * @param functionClass the class of the Function interface to use for this column * @param outputClass the class of the data type returned by the Function * @param propertyPath the Java Bean property to retrieve from the Output of the Function * @param columnName display name to use for the column */ public FunctionalPropertyColumn2(Class functionClass, Class outputClass, String propertyPath, String columnName) { super(getBeanInfo(outputClass), propertyPath, columnName); if (functionClass == null) throw new IllegalArgumentException("functionClass"); //$NON-NLS-1$ this.functionClass = functionClass; installDefaultFilter(); } /** * Construct a FunctionalPropertyColumn2 column * @param functionClass the class of the Function interface to use for this column * @param outputClass the class of the data type returned by the Function * @param propertyPath the Java Bean property to retrieve from the Output of the Function * @param columnId identifier used to reference the column * @param columnName display name to use for the column */ public FunctionalPropertyColumn2(Class functionClass, Class outputClass, String propertyPath, String columnId, String columnName) { this(functionClass, outputClass, propertyPath, columnName); if (StringUtils.isBlank(columnId)) throw new IllegalArgumentException("columnId"); //$NON-NLS-1$ setIdentifier(columnId); } @Override protected Output getBean(Input row) { F function = getRequiredFunction(functionClass); Output output = function.evaluate(row); return output; } @Override public void getRequiredFunctions(IFunctionGroup functions) { super.getRequiredFunctions(functions); functions.add(functionClass); } }