Class FilterConfigurationBuilder
DesignTimeConfiguration registered from code.
A configuration built by this builder belongs to the code that registers it, like a configuration declared in XML: it is created anew every time the view opens and is never stored. The user can change the values of its conditions, clear them and make the configuration their default one, but cannot edit, save or remove it. To change the conditions themselves, the user copies the configuration and saves the copy as their own configuration.
Encapsulates all required steps:
- Creating and configuring the root
GroupFilter - Adding filter components and recording their default values in the configuration
- Registering the configuration via
GenericFilter.addConfiguration(Configuration) - Optionally activating the configuration via
GenericFilter.setCurrentConfiguration(Configuration)
Obtain an instance via GenericFilter.filterConfigurationBuilder():
filter.filterConfigurationBuilder()
.id("openOrders")
.name("Open Orders")
.add(numberFilter)
.add(statusFilter, "NEW")
.makeCurrent()
.buildAndRegister();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected final List<FilterConfigurationBuilder.ComponentEntry> protected final GenericFilterprotected Stringprotected booleanprotected Stringprotected LogicalFilterComponent.Operation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(FilterComponent filterComponent) Adds a filter component using the component's current value (if any) as the default.add(SingleFilterComponentBase<V> filterComponent, @Nullable V defaultValue) Adds a filter component, overriding its default value.addAll(FilterComponent... filterComponents) Adds several filter components at once, each using its current value (if any) as the default.Builds theDesignTimeConfiguration, registers it with the filter, and optionally activates it.Sets the configuration id.Makes this configuration the current (active) one immediately after it is registered.Sets the configuration display name.operation(LogicalFilterComponent.Operation operation) Sets the logical operation of the root filter component.
-
Field Details
-
filter
-
id
-
name
-
operation
-
makeCurrent
protected boolean makeCurrent -
built
protected boolean built -
entries
-
-
Constructor Details
-
FilterConfigurationBuilder
-
-
Method Details
-
id
Sets the configuration id. Required.- Parameters:
id- unique configuration identifier within this filter
-
name
Sets the configuration display name.- Parameters:
name- display name shown in the configuration selector
-
operation
Sets the logical operation of the root filter component. Defaults toAND.- Parameters:
operation- logical operation
-
add
Adds a filter component using the component's current value (if any) as the default.- Parameters:
filterComponent- filter component to add
-
addAll
Adds several filter components at once, each using its current value (if any) as the default.- Parameters:
filterComponents- filter components to add
-
add
public <V> FilterConfigurationBuilder add(SingleFilterComponentBase<V> filterComponent, @Nullable V defaultValue) Adds a filter component, overriding its default value.The type parameter
Vensures thedefaultValuematches the component's own value type at compile time.- Type Parameters:
V- the value type of the filter component- Parameters:
filterComponent- filter component to adddefaultValue- value to apply and record as the configuration default
-
makeCurrent
Makes this configuration the current (active) one immediately after it is registered.This is not the persistent default configuration marker (set via the
genericFilter_makeDefaultaction and stored per user): it simply activates this configuration now, equivalent toGenericFilter.setCurrentConfiguration(Configuration). -
buildAndRegister
Builds theDesignTimeConfiguration, registers it with the filter, and optionally activates it.Automatically:
- Creates the root
GroupFilteras the filter creates it for a configuration declared in XML - Adds each filter component to the root
- Calls
setFilterComponentDefaultValuefor every component with a value, including the components nested in a group - Registers the configuration via
GenericFilter.addConfiguration(Configuration), where a run-time configuration with the same id, such as a stored one, gives way to it, and activates it viaGenericFilter.setCurrentConfiguration(Configuration)ifmakeCurrent()was requested
- Returns:
- the newly created and registered
DesignTimeConfiguration - Throws:
IllegalStateException- if this builder instance has already been used, ifidwas not set or is the id of the empty configuration, if a configuration with the same id that is not a run-time one, such as a design-time configuration, is already registered in the filter, or if the filter has no DataLoader
- Creates the root
-