Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the enable function in BindingsPropertiesProcessor #114

Open
lucky8987 opened this issue Nov 28, 2024 · 0 comments
Open

Define the enable function in BindingsPropertiesProcessor #114

lucky8987 opened this issue Nov 28, 2024 · 0 comments

Comments

@lucky8987
Copy link

Define the enable function in BindingsPropertiesProcessor like this:

/**
 * An interface for types that transform the contents of a {@link Bindings} into properties for injection into a
 * {@link org.springframework.core.env.PropertySource}.
 */
@FunctionalInterface
public interface BindingsPropertiesProcessor {

    /**
     * Transform the currently accumulated {@link Bindings}-related properties.
     *
     * @param environment the {@link Environment} that the processor is executing with.
     * @param bindings    the {@code Bindings} exposed to the application.
     * @param properties  the currently accumulated properties.
     */
    void process(Environment environment, Bindings bindings, Map<String, Object> properties);
    
    /**
     * Whether it is enabled the processor.
     * @param environment the {@link Environment} that the processor is executing with.
     * @return if true the to execute process.
     */
    default boolean enable(Environment environment) {
        return true;
    }

}

Processing the verification operations coupled in the process through the enable function is more reasonable in design, and the implementation of subclasses will also be more elegant.

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

No branches or pull requests

1 participant