Class FilterComponentBuilder
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent builder forGroupFilter.static classFluent builder forJpqlFilter.static classFluent builder forPropertyFilter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.springframework.context.ApplicationContextprotected final GenericFilter -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFilterComponentBuilder(GenericFilter filter, org.springframework.context.ApplicationContext applicationContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidcheckDataLoaderPresent(GenericFilter filter) Returns a builder for aGroupFilterbound to the owning filter.Returns a builder for a void (checkbox)JpqlFilter.jpqlFilter(Class<V> parameterClass) Returns a builder for a typedJpqlFilterwhose user-supplied value is bound to the query parameter.Returns a builder for aPropertyFilterbound to the owning filter.
-
Field Details
-
filter
-
applicationContext
protected final org.springframework.context.ApplicationContext applicationContext
-
-
Constructor Details
-
FilterComponentBuilder
protected FilterComponentBuilder(GenericFilter filter, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Details
-
propertyFilter
Returns a builder for aPropertyFilterbound to the owning filter.- Type Parameters:
V- the value type inferred from the entity property- Returns:
- a new
FilterComponentBuilder.PropertyFilterBuilder
-
jpqlFilter
Returns a builder for a void (checkbox)JpqlFilter.Use this variant for a condition with a fixed WHERE clause that carries no user-supplied value, e.g.
{E}.status = 'ACTIVE'. The filter is rendered as a checkbox: when checked the WHERE clause is applied, when unchecked it is omitted. The value type is thereforeBoolean; usedefaultValue(true)to make the condition active by default.- Returns:
- a new
FilterComponentBuilder.JpqlFilterBuilderthat produces a checkbox filter
-
jpqlFilter
Returns a builder for a typedJpqlFilterwhose user-supplied value is bound to the query parameter.- Type Parameters:
V- the value type- Parameters:
parameterClass- the Java class of the query parameter- Returns:
- a new
FilterComponentBuilder.JpqlFilterBuilder
-
groupFilter
Returns a builder for aGroupFilterbound to the owning filter.- Returns:
- a new
FilterComponentBuilder.GroupFilterBuilder
-
checkDataLoaderPresent
-