インターフェース BindHandler
- すべての既知の実装クラス:
AbstractBindHandler、BoundPropertiesTrackingBindHandler、IgnoreErrorsBindHandler、IgnoreTopLevelConverterNotFoundBindHandler、NoUnboundElementsBindHandler、ValidationBindHandler
public interface BindHandler
要素
binding 中に追加のロジックを処理するために使用できるコールバックインターフェース。- 導入:
- 2.0.0
- 作成者:
- Phillip Webb, Madhura Bhave
フィールドのサマリー
フィールドメソッドのサマリー
修飾子と型メソッド説明default ObjectSEonCreate(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) 要素のバインドがバインドされていない結果で終了し、新しく作成されたインスタンスが返されるときに呼び出されます。default ObjectSEonFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ExceptionSE error) バインドが何らかの理由で失敗した場合に呼び出されます(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)または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)呼び出しからの失敗を含む)。default voidonFinish(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) バインドがバインド済みまたはバインドなしの結果で終了したときに呼び出されます。default <T> Bindable<T>onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) 要素のバインドが開始されたときに、結果が決定される前に呼び出されます。default ObjectSEonSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) 要素のバインディングが成功した結果で終了すると呼び出されます。
フィールドの詳細
DEFAULT
デフォルトの no-op バインドハンドラー。
メソッドの詳細
onStart
default <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) 要素のバインドが開始されたときに、結果が決定される前に呼び出されます。- 型パラメーター:
T- バインド可能なソース型- パラメーター:
name- バインドされている要素の名前target- バインドされているアイテムcontext- バインドコンテキスト- 戻り値:
- バインドに使用される実際のアイテム (
nullの場合があります)
onSuccess
default ObjectSE onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) 要素のバインディングが成功した結果で終了すると呼び出されます。実装は、最終的に返される結果を変更したり、追加検証を実行したりする場合があります。- パラメーター:
name- バインドされている要素の名前target- バインドされているアイテムcontext- バインドコンテキストresult- バインドされた結果 (非null)- 戻り値:
- 使用すべき実際の結果 (
nullの場合があります)
onCreate
default ObjectSE onCreate(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) 要素のバインドがバインドされていない結果で終了し、新しく作成されたインスタンスが返されるときに呼び出されます。実装は、最終的に返される結果を変更したり、追加の検証を実行したりする場合があります。- パラメーター:
name- バインドされている要素の名前target- バインドされているアイテムcontext- バインドコンテキストresult- 新しく作成されたインスタンス (非null)- 戻り値:
- 使用すべき実際の結果 (
nullであってはなりません) - 導入:
- 2.2.2
onFailure
default ObjectSE onFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ExceptionSE error) throws ExceptionSE バインドが何らかの理由で失敗した場合に呼び出されます(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)または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)呼び出しからの失敗を含む)。実装は、例外を飲み込み、代替結果を返すことを選択できます。- パラメーター:
name- バインドされている要素の名前target- バインドされているアイテムcontext- バインドコンテキストerror- エラーの原因 (例外が発生した場合、再スローされる可能性があります)- 戻り値:
- 使用すべき実際の結果(
nullの場合があります)。 - 例外:
ExceptionSE- バインディングが有効でない場合
onFinish
default void onFinish(ConfigurationPropertyName name, Bindable<?> target, BindContext context, ObjectSE result) throws ExceptionSE バインドがバインド済みまたはバインドなしの結果で終了したときに呼び出されます。ハンドラーが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)から結果を返したとしても、バインディングが失敗した場合、このメソッドは呼び出されません。- パラメーター:
name- バインドされている要素の名前target- バインドされているアイテムcontext- バインドコンテキストresult- バインドされた結果 (nullの場合があります)- 例外:
ExceptionSE- バインディングが有効でない場合