return newColumn;
}
public AttributeColumn booleanLogicOperationsMerge(AttributeTable table, AttributeColumn[] columnsToMerge, BooleanOperations[] booleanOperations, String newColumnTitle) {
AttributeUtils attributeUtils = AttributeUtils.getDefault();
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
if (table == null || columnsToMerge == null || !attributeUtils.areAllColumnsOfType(columnsToMerge, AttributeType.BOOLEAN) || booleanOperations == null || booleanOperations.length != columnsToMerge.length - 1) {
throw new IllegalArgumentException("All columns have to be boolean columns, table, columns or operations can't be null and operations length must be columns length -1");
}
AttributeColumn newColumn;
newColumn = ac.addAttributeColumn(table, newColumnTitle, AttributeType.BOOLEAN);
if (newColumn == null) {
return null;
}
final int newColumnIndex = newColumn.getIndex();
Boolean value;
Boolean secondValue;
for (Attributes row : ac.getTableAttributeRows(table)) {
value = (Boolean) row.getValue(columnsToMerge[0].getIndex());
value = value != null ? value : false;//Use false if null
for (int i = 0; i < booleanOperations.length; i++) {
secondValue = (Boolean) row.getValue(columnsToMerge[i + 1].getIndex());
secondValue = secondValue != null ? secondValue : false;//Use false if null