Interface ConditionalConverter
- All Known Subinterfaces:
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.- Since:
- 3.2
- Author:
- Phillip Webb, Keith Donald
- See Also:
Converter
,GenericConverter
,ConverterFactory
,ConditionalGenericConverter
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
matches(TypeDescriptor sourceType, TypeDescriptor targetType)
Should the conversion fromsourceType
totargetType
currently under consideration be selected?
Method Detail
matches
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
Should the conversion fromsourceType
totargetType
currently under consideration be selected?- Parameters:
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to- Returns:
- true if conversion should be performed, false otherwise