Class ValidationBindHandler
- java.lang.Object
- org.springframework.boot.context.properties.bind.AbstractBindHandler
- org.springframework.boot.context.properties.bind.validation.ValidationBindHandler
- All Implemented Interfaces:
BindHandler
public class ValidationBindHandler extends AbstractBindHandler
BindHandler
to applyValidators
to bound results.- Since:
- 2.0.0
Field Summary
Fields inherited from interface org.springframework.boot.context.properties.bind.BindHandler
DEFAULT
Constructor Summary
Constructors Constructor Description ValidationBindHandler(BindHandler parent, org.springframework.validation.Validator... validators)
ValidationBindHandler(org.springframework.validation.Validator... validators)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onFinish(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result)
Called when binding finishes, regardless of whether the property was bound or not.Object
onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result)
Called when binding of an element ends with a successful result.Methods inherited from class org.springframework.boot.context.properties.bind.AbstractBindHandler
onFailure, onStart
Constructor Detail
ValidationBindHandler
public ValidationBindHandler(org.springframework.validation.Validator... validators)
ValidationBindHandler
public ValidationBindHandler(BindHandler parent, org.springframework.validation.Validator... validators)
Method Detail
onSuccess
public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result)
Description copied from interface:BindHandler
Called when binding of an element ends with a successful result. Implementations may change the ultimately returned result or perform addition validation.- Specified by:
onSuccess
in interfaceBindHandler
- Overrides:
onSuccess
in classAbstractBindHandler
- Parameters:
name
- the name of the element being boundtarget
- the item being boundcontext
- the bind contextresult
- the bound result (nevernull
)- Returns:
- the actual result that should be used (may be
null
)
onFinish
public void onFinish(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) throws Exception
Description copied from interface:BindHandler
Called when binding finishes, regardless of whether the property was bound or not.- Specified by:
onFinish
in interfaceBindHandler
- Overrides:
onFinish
in classAbstractBindHandler
- Parameters:
name
- the name of the element being boundtarget
- the item being boundcontext
- the bind contextresult
- the bound result (may benull
)- Throws:
Exception
- if the binding isn't valid