类 Binder
java.lang.Object
org.springframework.boot.context.properties.bind.Binder
A container object which Binds objects from one or more
ConfigurationPropertySources.- 从以下版本开始:
- 2.0.0
- 作者:
- Phillip Webb, Madhura Bhave
-
构造器概要
构造器构造器说明Binder(Iterable<ConfigurationPropertySource> sources) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, List<ConversionService> conversionServices, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler) Create a newBinderinstance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.Binder(ConfigurationPropertySource... sources) Create a newBinderinstance for the specified sources. -
方法概要
修饰符和类型方法说明<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, 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, 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, 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, BindHandler defaultBindHandler) Create a newBinderinstance from the specified environment.
-
构造器详细资料
-
Binder
Create a newBinderinstance for the specified sources. ADefaultFormattingConversionServicewill be used for all conversion.- 参数:
sources- the sources used for binding
-
Binder
Create a newBinderinstance for the specified sources. ADefaultFormattingConversionServicewill be used for all conversion.- 参数:
sources- the sources used for binding
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholders
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholdersconversionService- the conversion service to convert values (ornullto useApplicationConversionService)
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholdersconversionService- the conversion service to convert values (ornullto useApplicationConversionService)propertyEditorInitializer- initializer used to configure the property editors that can convert values (ornullif no initialization is required). Often used to callConfigurableBeanFactory.copyRegisteredEditorsTo(org.springframework.beans.PropertyEditorRegistry).
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholdersconversionService- the conversion service to convert values (ornullto useApplicationConversionService)propertyEditorInitializer- initializer used to configure the property editors that can convert values (ornullif no initialization is required). Often used to callConfigurableBeanFactory.copyRegisteredEditorsTo(org.springframework.beans.PropertyEditorRegistry).defaultBindHandler- the default bind handler to use if none is specified when binding- 从以下版本开始:
- 2.2.0
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholdersconversionService- the conversion service to convert values (ornullto useApplicationConversionService)propertyEditorInitializer- initializer used to configure the property editors that can convert values (ornullif no initialization is required). Often used to callConfigurableBeanFactory.copyRegisteredEditorsTo(org.springframework.beans.PropertyEditorRegistry).defaultBindHandler- the default bind handler to use if none is specified when bindingconstructorProvider- the constructor provider which provides the bind constructor to use when binding- 从以下版本开始:
- 2.2.1
-
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, List<ConversionService> conversionServices, Consumer<PropertyEditorRegistry> propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) Create a newBinderinstance for the specified sources.- 参数:
sources- the sources used for bindingplaceholdersResolver- strategy to resolve any property placeholdersconversionServices- the conversion services to convert values (ornullto useApplicationConversionService)propertyEditorInitializer- initializer used to configure the property editors that can convert values (ornullif no initialization is required). Often used to callConfigurableBeanFactory.copyRegisteredEditorsTo(org.springframework.beans.PropertyEditorRegistry).defaultBindHandler- the default bind handler to use if none is specified when bindingconstructorProvider- the constructor provider which provides the bind constructor to use when binding- 从以下版本开始:
- 2.5.0
-
-
方法详细资料
-
bind
Bind the specified targetClassusing this binder'sproperty sources.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target class- 返回:
- the binding result (never
null) - 另请参阅:
-
bind
Bind the specified targetBindableusing this binder'sproperty sources.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindable- 返回:
- the binding result (never
null) - 另请参阅:
-
bind
Bind the specified targetBindableusing this binder'sproperty sources.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindable- 返回:
- the binding result (never
null) - 另请参阅:
-
bind
Bind the specified targetBindableusing this binder'sproperty sources.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindablehandler- the bind handler (may benull)- 返回:
- the binding result (never
null)
-
bind
public <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler) Bind the specified targetBindableusing this binder'sproperty sources.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindablehandler- the bind handler (may benull)- 返回:
- the binding result (never
null)
-
bindOrCreate
Bind the specified targetClassusing this binder'sproperty sourcesor create a new instance of the specified targetClassif the result of the binding isnull.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target class- 返回:
- the bound or created object
- 从以下版本开始:
- 2.2.0
- 另请参阅:
-
bindOrCreate
Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindable- 返回:
- the bound or created object
- 从以下版本开始:
- 2.2.0
- 另请参阅:
-
bindOrCreate
Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- 类型参数:
T- the bound type- 参数:
name- the configuration property name to bindtarget- the target bindablehandler- the bind handler- 返回:
- the bound or created object
- 从以下版本开始:
- 2.2.0
- 另请参阅:
-
bindOrCreate
Bind the specified targetBindableusing this binder'sproperty sourcesor create a new instance using the type of theBindableif the result of the binding isnull.- 类型参数:
T- the bound or created type- 参数:
name- the configuration property name to bindtarget- the target bindablehandler- the bind handler (may benull)- 返回:
- the bound or created object
- 从以下版本开始:
- 2.2.0
-
get
Create a newBinderinstance from the specified environment.- 参数:
environment- the environment source (must have attachedConfigurationPropertySources)- 返回:
- a
Binderinstance
-
get
Create a newBinderinstance from the specified environment.- 参数:
environment- the environment source (must have attachedConfigurationPropertySources)defaultBindHandler- the default bind handler to use if none is specified when binding- 返回:
- a
Binderinstance - 从以下版本开始:
- 2.2.0
-