public interface ConditionalConverter
Converter
、GenericConverter
、ConverterFactory
が、source
および target
TypeDescriptor
の属性に基づいて条件付きで実行できるようにします。 多くの場合、アノテーションやメソッドなどのフィールドまたはクラスレベルの特性の存在に基づいて、カスタム変換ロジックを選択的に照合するために使用されます。例: 文字列フィールドから日付フィールドに変換するときに、ターゲットフィールドにも @DateTimeFormat
アノテーションが付けられている場合、実装は true
を返す場合があります。
別の例として、String フィールドから Account
フィールドに変換するときに、ターゲットの Account クラスが public static findAccount(String)
メソッドを定義している場合、実装は true
を返す場合があります。
Converter
, GenericConverter
, ConverterFactory
, ConditionalGenericConverter
修飾子と型 | メソッドと説明 |
---|---|
boolean | matches(TypeDescriptor sourceType, TypeDescriptor targetType) 現在検討中の sourceType から targetType への変換を選択する必要がありますか? |
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
sourceType
から targetType
への変換を選択する必要がありますか? sourceType
- 変換元のフィールドの型記述子 targetType
- 変換先のフィールドの型記述子