Interface ConfigurationBeanBinder

All Known Implementing Classes:
DefaultConfigurationBeanBinder

public interface ConfigurationBeanBinder
A binder interface for mapping configuration properties to a configuration bean.

It provides methods to bind properties from an environment into a target bean, handling unknown and invalid fields according to the provided flags.

Example Usage


 // Create or obtain an instance of ConfigurationBeanBinder
 ConfigurationBeanBinder binder = new DefaultConfigurationBeanBinder();

 // Prepare the configuration properties map
 Map<String, Object> properties = new HashMap<>();
 properties.put("user.configKey", "configValue");

 // Target configuration bean
 MyConfigurationBean configBean = new MyConfigurationBean();

 // Bind the properties into the bean
 binder.bind(properties, true, false, configBean);
 
Since:
1.0.0
Author:
Mercy
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bind(Map<String,Object> configurationProperties, boolean ignoreUnknownFields, boolean ignoreInvalidFields, Object configurationBean)
    Bind the properties in the Environment to Configuration bean under specified prefix.
    default void
    setConversionService(org.springframework.core.convert.ConversionService conversionService)
    Set the ConversionService
  • Method Details

    • bind

      void bind(Map<String,Object> configurationProperties, boolean ignoreUnknownFields, boolean ignoreInvalidFields, Object configurationBean)
      Bind the properties in the Environment to Configuration bean under specified prefix.
      Parameters:
      configurationProperties - The configuration properties
      ignoreUnknownFields - whether to ignore unknown fields, the value is come from the attribute of EnableConfigurationBeanBinding.ignoreUnknownFields()
      ignoreInvalidFields - whether to ignore invalid fields, the value is come from the attribute of EnableConfigurationBeanBinding.ignoreInvalidFields()
      configurationBean - the bean of configuration
    • setConversionService

      default void setConversionService(@Nullable org.springframework.core.convert.ConversionService conversionService)
      Set the ConversionService
      Parameters:
      conversionService - ConversionService