Skip to content

Several improvements to GenericFilter's programmatic API #5083#5362

Draft
fractal3000 wants to merge 1 commit into
masterfrom
feature/5083-several-improvements-to-generic-filters-programmatic-API
Draft

Several improvements to GenericFilter's programmatic API #5083#5362
fractal3000 wants to merge 1 commit into
masterfrom
feature/5083-several-improvements-to-generic-filters-programmatic-API

Conversation

@fractal3000

@fractal3000 fractal3000 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

#5083

  • MutableConfiguration: new interface extending Configuration with all  mutating methods. RunTimeConfiguration now implements MutableConfiguration instead of Configuration, giving compile-time safety against calling mutating methods on a DesignTimeConfiguration. Mutating methods on Configuration are deprecated in favour of MutableConfiguration.

  • addAndSetCurrentConfiguration(): atomic alternative to calling  addConfiguration() followed by setCurrentConfiguration(). The two-step  sequence silently does nothing when the configuration has not yet been
      registered at the time setCurrentConfiguration is invoked.

  • refreshCurrentConfiguration(): stable public method to re-render the filter UI after programmatic modification of the current configuration. Was previously only accessible as the protected refreshCurrentConfigurationLayout().

  • MutableConfiguration.protectedFromUserDeletion: flag that prevents the user from deleting a programmatic configuration through the UI. When true, GenericFilterRemoveAction hides the Remove button for that configuration,
      and GenericFilter.removeConfiguration() silently skips it.

@fractal3000 fractal3000 linked an issue Jun 8, 2026 that may be closed by this pull request
@fractal3000 fractal3000 requested a review from KremnevDmitry June 8, 2026 19:55
…nfiguration() and refreshCurrentConfiguration() #5083

- MutableConfiguration: new interface extending Configuration with all
  mutating methods. RunTimeConfiguration now implements MutableConfiguration
  instead of Configuration, giving compile-time safety against calling
  mutating methods on a DesignTimeConfiguration. Mutating methods on
  Configuration are deprecated in favour of MutableConfiguration.

- addAndSetCurrentConfiguration(): atomic alternative to calling
  addConfiguration() followed by setCurrentConfiguration(). The two-step
  sequence silently does nothing when the configuration has not yet been
  registered at the time setCurrentConfiguration is invoked.

- refreshCurrentConfiguration(): stable public method to re-render the
  filter UI after programmatic modification of the current configuration.
  Was previously only accessible as the protected refreshCurrentConfigurationLayout().

- MutableConfiguration.protectedFromUserDeletion: flag that prevents the
  user from deleting a programmatic configuration through the UI. When true,
  GenericFilterRemoveAction hides the Remove button for that configuration,
  and GenericFilter.removeConfiguration() silently skips it.
@fractal3000 fractal3000 force-pushed the feature/5083-several-improvements-to-generic-filters-programmatic-API branch from 3c398dc to 7564686 Compare June 8, 2026 22:00
import io.jmix.flowui.component.logicalfilter.LogicalFilterComponent;

import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using jspecify nullability annotations, spring nullable is deprecated

Comment on lines +27 to +38
* <p>
* {@link RunTimeConfiguration} implements this interface. {@link DesignTimeConfiguration}
* only implements the read-only {@link Configuration}.
* <p>
* Use this interface as the declared type when you need to call mutating methods,
* so the compiler catches misuse of {@link DesignTimeConfiguration} at compile time:
* <pre>{@code
* MutableConfiguration config = filter.runtimeConfigurationBuilder()
* .id("myConfig")
* .buildAndRegister();
* config.setModified(true);
* }</pre>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a useless information, especially about implementations. Moreover, there is no runtimeConfigurationBuilder and such API on this moment.

* @see Configuration
* @see RunTimeConfiguration
*/
@SuppressWarnings({"deprecation", "removal"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't suppress this warnings on whole class

public interface MutableConfiguration extends Configuration {

/**
* Returns whether the configuration is modified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@returns should be used, the same for all classes

Comment on lines +188 to 191
@Deprecated(since = "3.0", forRemoval = true)
default boolean isAvailableForAllUsers() {
return false;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method shouldn't be deprecated because it used for calculating configuration name for all types of configuration

*
* @param name a configuration name
* @throws UnsupportedOperationException when called on {@link DesignTimeConfiguration}
* @deprecated use {@link MutableConfiguration} instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For use instead we should pass the appropriate methods in new interface e.g.:{@link MutableConfiguration#setName}

if (configuration != getEmptyConfiguration()
&& !(configuration instanceof DesignTimeConfiguration)) {
&& !(configuration instanceof DesignTimeConfiguration)
&& !(configuration instanceof MutableConfiguration mc && mc.isProtectedFromUserDeletion())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't re-check this condition here. The runtime configuration should be available for internal removing, e.g. for the renaming process in the io.jmix.flowui.component.genericfilter.GenericFilterSupport#initFilterConfiguration. Otherwise the configuration will be duplicated.

Availablility of user-deletion should be handled (and already handled) in the GenericFilterRemoveAction isApplicable method.

* {@link UnsupportedOperationException} when called on a {@link DesignTimeConfiguration}.
* Those methods are deprecated — use {@link MutableConfiguration} when you need to call them.
*/
public interface Configuration extends Comparable<Configuration> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a lot of calls of all deprecated method. I think we should rewrite out own API if it is possible. Otherwise why do we introduce a new API if we are not using it.

Don't forget about backward compatibility.

Comment on lines +617 to +620
public void addAndSetCurrentConfiguration(Configuration configuration) {
addConfiguration(configuration);
setCurrentConfiguration(configuration);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a useless method. I think we should throw an exception or write a error log message when the user or programmer trying to set current configuration which does not exist.

@fractal3000 fractal3000 marked this pull request as draft June 15, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Several improvements to GenericFilter's programmatic API

2 participants