org.springframework.core.convert.converter
Interface ConditionalGenericConverter
- All Superinterfaces:
- GenericConverter
public interface ConditionalGenericConverter
- extends GenericConverter
A generic converter that conditionally executes.
Applies a rule that determines if a converter between a set of
convertible types
matches given a client request to
convert between a source field of convertible type S and a target field of convertible type T.
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 return true if the target Account class defines a
public static findAccount(String)
method.
- Since:
- 3.0
- Author:
- Keith Donald
Method Summary |
boolean |
matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
Should the converter from sourceType to targetType
currently under consideration be selected? |
matches
boolean matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
- Should the converter from
sourceType
to targetType
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