Skip to content

Define the enable function in BindingsPropertiesProcessor #114

@lucky8987

Description

@lucky8987

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions