Class Binder
- java.lang.Object
- org.springframework.boot.context.properties.bind.Binder
public class Binder extends Object
A container object which Binds objects from one or moreConfigurationPropertySources
.- Since:
- 2.0.0
Constructor Summary
Constructors Constructor Description Binder(Iterable<ConfigurationPropertySource> sources)
Create a newBinder
instance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver)
Create a newBinder
instance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, org.springframework.core.convert.ConversionService conversionService)
Create a newBinder
instance for the specified sources.Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, org.springframework.core.convert.ConversionService conversionService, Consumer<org.springframework.beans.PropertyEditorRegistry> propertyEditorInitializer)
Create a newBinder
instance for the specified sources.Binder(ConfigurationPropertySource... sources)
Create a newBinder
instance for the specified sources.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> BindResult<T>
bind(String name, Class<T> target)
Bind the specified targetClass
using this binder'sproperty sources
.<T> BindResult<T>
bind(String name, Bindable<T> target)
Bind the specified targetBindable
using this binder'sproperty sources
.<T> BindResult<T>
bind(String name, Bindable<T> target, BindHandler handler)
Bind the specified targetBindable
using this binder'sproperty sources
.<T> BindResult<T>
bind(ConfigurationPropertyName name, Bindable<T> target)
Bind the specified targetBindable
using this binder'sproperty sources
.<T> BindResult<T>
bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler)
Bind the specified targetBindable
using this binder'sproperty sources
.protected <T> T
bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler, org.springframework.boot.context.properties.bind.Binder.Context context, boolean allowRecursiveBinding)
static Binder
get(org.springframework.core.env.Environment environment)
Create a newBinder
instance from the specified environment.
Constructor Detail
Binder
public Binder(ConfigurationPropertySource... sources)
Create a newBinder
instance for the specified sources. ADefaultFormattingConversionService
will be used for all conversion.- Parameters:
sources
- the sources used for binding
Binder
public Binder(Iterable<ConfigurationPropertySource> sources)
Create a newBinder
instance for the specified sources. ADefaultFormattingConversionService
will be used for all conversion.- Parameters:
sources
- the sources used for binding
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver)
Create a newBinder
instance for the specified sources.- Parameters:
sources
- the sources used for bindingplaceholdersResolver
- strategy to resolve any property placeholders
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, org.springframework.core.convert.ConversionService conversionService)
Create a newBinder
instance for the specified sources.- Parameters:
sources
- the sources used for bindingplaceholdersResolver
- strategy to resolve any property placeholdersconversionService
- the conversion service to convert values (ornull
to useApplicationConversionService
)
Binder
public Binder(Iterable<ConfigurationPropertySource> sources, PlaceholdersResolver placeholdersResolver, org.springframework.core.convert.ConversionService conversionService, Consumer<org.springframework.beans.PropertyEditorRegistry> propertyEditorInitializer)
Create a newBinder
instance for the specified sources.- Parameters:
sources
- the sources used for bindingplaceholdersResolver
- strategy to resolve any property placeholdersconversionService
- the conversion service to convert values (ornull
to useApplicationConversionService
)propertyEditorInitializer
- initializer used to configure the property editors that can convert values (ornull
if no initialization is required). Often used to callConfigurableBeanFactory.copyRegisteredEditorsTo(org.springframework.beans.PropertyEditorRegistry)
.
Method Detail
bind
public <T> BindResult<T> bind(String name, Class<T> target)
Bind the specified targetClass
using this binder'sproperty sources
.- Type Parameters:
T
- the bound type- Parameters:
name
- the configuration property name to bindtarget
- the target class- Returns:
- the binding result (never
null
) - See Also:
bind(ConfigurationPropertyName, Bindable, BindHandler)
bind
public <T> BindResult<T> bind(String name, Bindable<T> target)
Bind the specified targetBindable
using this binder'sproperty sources
.- Type Parameters:
T
- the bound type- Parameters:
name
- the configuration property name to bindtarget
- the target bindable- Returns:
- the binding result (never
null
) - See Also:
bind(ConfigurationPropertyName, Bindable, BindHandler)
bind
public <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target)
Bind the specified targetBindable
using this binder'sproperty sources
.- Type Parameters:
T
- the bound type- Parameters:
name
- the configuration property name to bindtarget
- the target bindable- Returns:
- the binding result (never
null
) - See Also:
bind(ConfigurationPropertyName, Bindable, BindHandler)
bind
public <T> BindResult<T> bind(String name, Bindable<T> target, BindHandler handler)
Bind the specified targetBindable
using this binder'sproperty sources
.- Type Parameters:
T
- the bound type- Parameters:
name
- the configuration property name to bindtarget
- the target bindablehandler
- the bind handler (may benull
)- Returns:
- the binding result (never
null
)
bind
public <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler)
Bind the specified targetBindable
using this binder'sproperty sources
.- Type Parameters:
T
- the bound type- Parameters:
name
- the configuration property name to bindtarget
- the target bindablehandler
- the bind handler (may benull
)- Returns:
- the binding result (never
null
)
bind
protected final <T> T bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler, org.springframework.boot.context.properties.bind.Binder.Context context, boolean allowRecursiveBinding)
get
public static Binder get(org.springframework.core.env.Environment environment)
Create a newBinder
instance from the specified environment.- Parameters:
environment
- the environment source (must have attachedConfigurationPropertySources
)- Returns:
- a
Binder
instance