Class NoUnboundElementsBindHandler
java.lang.Object
org.springframework.boot.context.properties.bind.AbstractBindHandler
org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler
- All Implemented Interfaces:
BindHandler
BindHandler
to enforce that all configuration properties under the root name
have been bound.- Since:
- 2.0.0
-
Field Summary
Fields inherited from interface org.springframework.boot.context.properties.bind.BindHandler
DEFAULT
-
Constructor Summary
ConstructorDescriptionNoUnboundElementsBindHandler
(BindHandler parent, Function<ConfigurationPropertySource, Boolean> filter) -
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
-
NoUnboundElementsBindHandler
-
NoUnboundElementsBindHandler
public NoUnboundElementsBindHandler(BindHandler parent, Function<ConfigurationPropertySource, Boolean> filter)
-
-
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
- Overrides:
onStart
in classAbstractBindHandler
- 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
- 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
)
-
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
- Overrides:
onFailure
in classAbstractBindHandler
- 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
- 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
-