Class AbstractBindHandler
java.lang.Object
org.springframework.boot.context.properties.bind.AbstractBindHandler
- All Implemented Interfaces:
BindHandler
- Direct Known Subclasses:
BoundPropertiesTrackingBindHandler
,IgnoreErrorsBindHandler
,IgnoreTopLevelConverterNotFoundBindHandler
,NoUnboundElementsBindHandler
,ValidationBindHandler
Abstract base class for
BindHandler
implementations.- Since:
- 2.0.0
- Author:
- Phillip Webb, Madhura Bhave
-
Field Summary
Fields inherited from interface org.springframework.boot.context.properties.bind.BindHandler
DEFAULT
-
Constructor Summary
ConstructorDescriptionCreate a new binding handler instance.AbstractBindHandler
(BindHandler parent) Create a new binding handler instance with a specific parent. -
Method Summary
Modifier and TypeMethodDescriptiononFailure
(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Exception error) 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)
orBindHandler.onCreate(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).void
onFinish
(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) Called when binding finishes with either bound or unbound result.<T> Bindable<T>
onStart
(ConfigurationPropertyName name, Bindable<T> target, BindContext context) Called when binding of an element starts but before any result has been determined.onSuccess
(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) Called when binding of an element ends with a successful result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.boot.context.properties.bind.BindHandler
onCreate
-
Constructor Details
-
AbstractBindHandler
public AbstractBindHandler()Create a new binding handler instance. -
AbstractBindHandler
Create a new binding handler instance with a specific parent.- Parameters:
parent
- the parent handler
-
-
Method Details
-
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)
orBindHandler.onCreate(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 with either bound or unbound result. This method will not be called when binding failed, even if a handler returns a result fromBindHandler.onFailure(org.springframework.boot.context.properties.source.ConfigurationPropertyName, org.springframework.boot.context.properties.bind.Bindable<?>, org.springframework.boot.context.properties.bind.BindContext, java.lang.Exception)
.- 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
-