Class FilterComponentBuilder

java.lang.Object
io.jmix.flowui.component.genericfilter.FilterComponentBuilder

public class FilterComponentBuilder extends Object
A factory for creating filter components (PropertyFilter, JpqlFilter, GroupFilter) that are pre-configured for use inside a specific GenericFilter.

Single filter components are built by assembling a condition model from the fluent parameters and delegating to the same converter the framework uses when loading a filter from XML or adding a condition through the UI. The converter is the single source of truth for component initialisation, so a programmatically built component behaves exactly like a declarative one.

The owning GenericFilter must have a DataLoader; otherwise build() throws an IllegalStateException.

This factory and its nested builders are designed for extension: their constructors and fields are protected. To customise behaviour, subclass FilterComponentBuilder and override the relevant factory method (propertyFilter(), jpqlFilter(), groupFilter()) to return your own builder subclass, then return your factory from a GenericFilter subclass that overrides GenericFilter.filterComponentBuilder().

Obtain an instance via GenericFilter.filterComponentBuilder():


 FilterComponentBuilder builder = filter.filterComponentBuilder();

 PropertyFilter<String> nameFilter = builder.propertyFilter()
         .property("name")
         .operation(PropertyFilter.Operation.CONTAINS)
         .defaultValue("Acme")
         .build();

 // void (checkbox) filter: toggles a fixed condition on/off
 JpqlFilter<Boolean> activeFilter = builder.jpqlFilter()
         .where("{E}.status = 'ACTIVE'")
         .defaultValue(true)
         .build();

 // typed filter: a user-supplied value is bound to the query parameter
 JpqlFilter<String> codeFilter = builder.jpqlFilter(String.class)
         .where("{E}.code = ?")
         .build();