Class AbstractBindHandler
- java.lang.Object
- org.springframework.boot.context.properties.bind.AbstractBindHandler
- All Implemented Interfaces:
BindHandler
- Direct Known Subclasses:
IgnoreErrorsBindHandler
,IgnoreTopLevelConverterNotFoundBindHandler
,NoUnboundElementsBindHandler
,ValidationBindHandler
public abstract class AbstractBindHandler extends Object implements BindHandler
Abstract base class forBindHandler
implementations.- Since:
- 2.0.0
Field Summary
Fields inherited from interface org.springframework.boot.context.properties.bind.BindHandler
DEFAULT
Constructor Summary
Constructors Constructor Description AbstractBindHandler()
Create a new binding handler instance.AbstractBindHandler(BindHandler parent)
Create a new binding handler instance with a specific parent.
Method Summary
Constructor Detail
AbstractBindHandler
public AbstractBindHandler()
Create a new binding handler instance.
AbstractBindHandler
public AbstractBindHandler(BindHandler parent)
Create a new binding handler instance with a specific parent.- Parameters:
parent
- the parent handler
Method Detail
onStart
public <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context)
Description copied from interface:BindHandler
Called when binding of an element starts but before any result has been determined.- Specified by:
onStart
in interfaceBindHandler
- Type Parameters:
T
- the bindable source type- Parameters:
name
- the name of the element being boundtarget
- the item being boundcontext
- the bind context- Returns:
- the actual item that should be used for binding (may be
null
)
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
- 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
)
onFailure
public Object onFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Exception error) throws Exception
Description copied from interface:BindHandler
Called when binding fails for any reason (including failures fromBindHandler.onSuccess(org.springframework.boot.context.properties.source.ConfigurationPropertyName, org.springframework.boot.context.properties.bind.Bindable<?>, org.springframework.boot.context.properties.bind.BindContext, java.lang.Object)
calls). Implementations may choose to swallow exceptions and return an alternative result.- Specified by:
onFailure
in interfaceBindHandler
- Parameters:
name
- the name of the element being boundtarget
- the item being boundcontext
- the bind contexterror
- the cause of the error (if the exception stands it may be re-thrown)- Returns:
- the actual result that should be used (may be
null
). - Throws:
Exception
- if the binding isn't valid
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
- 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