spring-cloud-bindings
spring-cloud-bindings copied to clipboard
Define the enable function in BindingsPropertiesProcessor
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.