Class FilterConfigurationBuilder

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

public class FilterConfigurationBuilder extends Object
Fluent builder for a 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:

Obtain an instance via GenericFilter.filterConfigurationBuilder():


 filter.filterConfigurationBuilder()
       .id("openOrders")
       .name("Open Orders")
       .add(numberFilter)
       .add(statusFilter, "NEW")
       .makeCurrent()
       .buildAndRegister();
 
  • Field Details

  • Constructor Details

    • FilterConfigurationBuilder

      protected FilterConfigurationBuilder(GenericFilter filter)
  • Method Details

    • id

      Sets the configuration id. Required.
      Parameters:
      id - unique configuration identifier within this filter
    • name

      public FilterConfigurationBuilder name(@Nullable String 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 to AND.
      Parameters:
      operation - logical operation
    • add

      public FilterConfigurationBuilder add(FilterComponent filterComponent)
      Adds a filter component using the component's current value (if any) as the default.
      Parameters:
      filterComponent - filter component to add
    • addAll

      public FilterConfigurationBuilder addAll(FilterComponent... filterComponents)
      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 V ensures the defaultValue matches the component's own value type at compile time.

      Type Parameters:
      V - the value type of the filter component
      Parameters:
      filterComponent - filter component to add
      defaultValue - value to apply and record as the configuration default
    • makeCurrent

      public FilterConfigurationBuilder 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_makeDefault action and stored per user): it simply activates this configuration now, equivalent to GenericFilter.setCurrentConfiguration(Configuration).

    • buildAndRegister

      public DesignTimeConfiguration buildAndRegister()
      Builds the DesignTimeConfiguration, registers it with the filter, and optionally activates it.

      Automatically:

      Returns:
      the newly created and registered DesignTimeConfiguration
      Throws:
      IllegalStateException - if this builder instance has already been used, if id was 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