use of org.jowidgets.cap.ui.api.filter.IUiCustomFilterBuilder in project jo-client-platform by jo-source.
the class UiFilterToolsImpl method invert.
@SuppressWarnings("unchecked")
@Override
public IUiFilter invert(final IUiFilter sourceFilter) {
Assert.paramNotNull(sourceFilter, "sourceFilter");
final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
if (sourceFilter instanceof IUiBooleanFilter) {
final IUiBooleanFilter source = (IUiBooleanFilter) sourceFilter;
final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
builder.setOperator(source.getOperator());
builder.setInverted(!source.isInverted());
builder.setFilters(source.getFilters());
return builder.build();
} else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
final IUiArithmeticFilter<Object> source = (IUiArithmeticFilter<Object>) sourceFilter;
final IUiArithmeticFilterBuilder<Object> builder = filterFactory.arithmeticFilterBuilder();
builder.setOperator(source.getOperator());
builder.setPropertyName(source.getPropertyName());
builder.setParameters(source.getParameters());
builder.setConfig(source.getConfig());
builder.setInverted(!source.isInverted());
return builder.build();
} else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
final IUiArithmeticPropertyFilter<Object> source = (IUiArithmeticPropertyFilter<Object>) sourceFilter;
final IUiArithmeticPropertyFilterBuilder<Object> builder = filterFactory.arithmeticPropertyFilterBuilder();
builder.setOperator(source.getOperator());
builder.setPropertyName(source.getPropertyName());
builder.setRightHandPropertyNames(source.getRightHandPropertyNames());
builder.setConfig(source.getConfig());
builder.setInverted(!source.isInverted());
return builder.build();
} else if (sourceFilter instanceof IUiCustomFilter<?>) {
final IUiCustomFilter<Object> source = (IUiCustomFilter<Object>) sourceFilter;
final IUiCustomFilterBuilder<Object> builder = filterFactory.customFilterBuilder();
builder.setOperator(source.getOperator());
builder.setPropertyName(source.getPropertyName());
builder.setValue(source.getValue());
builder.setFilterType(source.getFilterType());
builder.setConfig(source.getConfig());
builder.setInverted(!source.isInverted());
return builder.build();
} else {
throw new IllegalArgumentException("The source filter type '" + sourceFilter.getClass().getName() + "' is not supported");
}
}
Aggregations