Class Binder
java.lang.Object
org.springframework.boot.context.properties.bind.Binder
A container object which Binds objects from one or more
ConfigurationPropertySources.- Since:
- 2.0.0
- Author:
- Phillip Webb, Madhura Bhave
- 
Constructor SummaryConstructorsConstructorDescriptionBinder(Iterable<ConfigurationPropertySource> sources) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable List<ConversionService> conversionServices, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler, @Nullable BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler, @Nullable BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.Binder(ConfigurationPropertySource... sources) Create a newBinderinstance for the specified sources.
- 
Method SummaryModifier and TypeMethodDescription<T> BindResult<T> Bind the specified targetClassusing this binder'sproperty sources.<T> BindResult<T> Bind the specified targetBindableusing this binder'sproperty sources.<T> BindResult<T> bind(String name, Bindable<T> target, @Nullable BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sources.<T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target) Bind the specified targetBindableusing this binder'sproperty sources.<T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target, @Nullable BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sources.<T> TbindOrCreate(String name, Class<T> target) Bind the specified targetClassusing this binder'sproperty sourcesor create a new instance of the specified targetClassif the result of the binding isnull.<T> TbindOrCreate(String name, Bindable<T> target) Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.<T> TbindOrCreate(String name, Bindable<T> target, BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.<T> TbindOrCreate(ConfigurationPropertyName name, Bindable<T> target, @Nullable BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.static Binderget(Environment environment) Create a newBinderinstance from the specified environment.static Binderget(Environment environment, @Nullable BindHandler defaultBindHandler) Create a newBinderinstance from the specified environment.
- 
Constructor Details- 
BinderCreate a newBinderinstance for the specified sources. ADefaultFormattingConversionServicewill be used for all conversion.- Parameters:
- sources- the sources used for binding
 
- 
BinderCreate a newBinderinstance for the specified sources. ADefaultFormattingConversionServicewill be used for all conversion.- Parameters:
- sources- the sources used for binding
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
- conversionService- the conversion service to convert values (or- nullto use- ApplicationConversionService)
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
- conversionService- the conversion service to convert values (or- nullto use- ApplicationConversionService)
- propertyEditorInitializer- initializer used to configure the property editors that can convert values (or- nullif no initialization is required). Often used to call- ConfigurableBeanFactory.copyRegisteredEditorsTo(PropertyEditorRegistry).
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
- conversionService- the conversion service to convert values (or- nullto use- ApplicationConversionService)
- propertyEditorInitializer- initializer used to configure the property editors that can convert values (or- nullif no initialization is required). Often used to call- ConfigurableBeanFactory.copyRegisteredEditorsTo(PropertyEditorRegistry).
- defaultBindHandler- the default bind handler to use if none is specified when binding
- Since:
- 2.2.0
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable ConversionService conversionService, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler, @Nullable BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
- conversionService- the conversion service to convert values (or- nullto use- ApplicationConversionService)
- propertyEditorInitializer- initializer used to configure the property editors that can convert values (or- nullif no initialization is required). Often used to call- ConfigurableBeanFactory.copyRegisteredEditorsTo(PropertyEditorRegistry).
- defaultBindHandler- the default bind handler to use if none is specified when binding
- constructorProvider- the constructor provider which provides the bind constructor to use when binding
- Since:
- 2.2.1
 
- 
Binderpublic Binder(Iterable<ConfigurationPropertySource> sources, @Nullable PlaceholdersResolver placeholdersResolver, @Nullable List<ConversionService> conversionServices, @Nullable Consumer<PropertyEditorRegistry> propertyEditorInitializer, @Nullable BindHandler defaultBindHandler, @Nullable BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.- Parameters:
- sources- the sources used for binding
- placeholdersResolver- strategy to resolve any property placeholders
- conversionServices- the conversion services to convert values (or- nullto use- ApplicationConversionService)
- propertyEditorInitializer- initializer used to configure the property editors that can convert values (or- nullif no initialization is required). Often used to call- ConfigurableBeanFactory.copyRegisteredEditorsTo(PropertyEditorRegistry).
- defaultBindHandler- the default bind handler to use if none is specified when binding
- constructorProvider- the constructor provider which provides the bind constructor to use when binding
- Since:
- 2.5.0
 
 
- 
- 
Method Details- 
bindBind the specified targetClassusing this binder'sproperty sources.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target class
- Returns:
- the binding result (never null)
- See Also:
 
- 
bindBind the specified targetBindableusing this binder'sproperty sources.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- Returns:
- the binding result (never null)
- See Also:
 
- 
bindBind the specified targetBindableusing this binder'sproperty sources.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- Returns:
- the binding result (never null)
- See Also:
 
- 
bindBind the specified targetBindableusing this binder'sproperty sources.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- handler- the bind handler (may be- null)
- Returns:
- the binding result (never null)
 
- 
bindpublic <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target, @Nullable BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sources.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- handler- the bind handler (may be- null)
- Returns:
- the binding result (never null)
 
- 
bindOrCreateBind the specified targetClassusing this binder'sproperty sourcesor create a new instance of the specified targetClassif the result of the binding isnull.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target class
- Returns:
- the bound or created object
- Since:
- 2.2.0
- See Also:
 
- 
bindOrCreateBind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- Returns:
- the bound or created object
- Since:
- 2.2.0
- See Also:
 
- 
bindOrCreateBind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- Type Parameters:
- T- the bound type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- handler- the bind handler
- Returns:
- the bound or created object
- Since:
- 2.2.0
- See Also:
 
- 
bindOrCreatepublic <T> T bindOrCreate(ConfigurationPropertyName name, Bindable<T> target, @Nullable BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- Type Parameters:
- T- the bound or created type
- Parameters:
- name- the configuration property name to bind
- target- the target bindable
- handler- the bind handler (may be- null)
- Returns:
- the bound or created object
- Since:
- 2.2.0
 
- 
getCreate a newBinderinstance from the specified environment.- Parameters:
- environment- the environment source (must have attached- ConfigurationPropertySources)
- Returns:
- a Binderinstance
 
- 
getCreate a newBinderinstance from the specified environment.- Parameters:
- environment- the environment source (must have attached- ConfigurationPropertySources)
- defaultBindHandler- the default bind handler to use if none is specified when binding
- Returns:
- a Binderinstance
- Since:
- 2.2.0
 
 
-