接口 ConditionalConverter
- 所有已知子接口:
ConditionalGenericConverter
public interface ConditionalConverter
Allows aConverter
,GenericConverter
orConverterFactory
to conditionally execute based on attributes of thesource
andtarget
TypeDescriptor
.Often used to selectively match custom conversion logic based on the presence of a field or class-level characteristic, such as an annotation or method. For example, when converting from a String field to a Date field, an implementation might return
true
if the target field has also been annotated with@DateTimeFormat
.As another example, when converting from a String field to an
Account
field, an implementation might returntrue
if the target Account class defines apublic static findAccount(String)
method.- 从以下版本开始:
- 3.2
- 作者:
- Phillip Webb, Keith Donald
- 另请参阅:
Converter
,GenericConverter
,ConverterFactory
,ConditionalGenericConverter
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 boolean
matches(TypeDescriptor sourceType, TypeDescriptor targetType)
Should the conversion fromsourceType
totargetType
currently under consideration be selected?
方法详细资料
matches
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
Should the conversion fromsourceType
totargetType
currently under consideration be selected?- 参数:
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to- 返回:
- true if conversion should be performed, false otherwise