Top Description Methods
org.springframework.core.convert.converter

public Interface ConditionalConverter

Known Direct Subinterfaces
org.springframework.core.convert.converter.ConditionalGenericConverter
Known Direct Implementers
org.springframework.core.convert.support.AbstractConditionalEnumConverter, org.springframework.core.convert.support.NumberToNumberConverterFactory
Imports
org.springframework.core.convert.TypeDescriptor

Allows a Converter, GenericConverter or ConverterFactory to conditionally execute based on attributes of the source and target 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 return true if the target Account class defines a public static findAccount(String) method.

Authors
Phillip Webb, Keith Donald
Since
3.2
See Also
Converter, GenericConverter, ConverterFactory, ConditionalGenericConverter

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if conversion should be performed, false otherwise
matches
(TypeDescriptor
the type descriptor of the field we are converting from
sourceType
,
TypeDescriptor
the type descriptor of the field we are converting to
targetType
)

Should the conversion from sourceType to targetType currently under consideration be selected?

Method Detail

matchesback to summary
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)

Should the conversion from sourceType to targetType currently under consideration be selected?

Parameters
sourceType:TypeDescriptor

the type descriptor of the field we are converting from

targetType:TypeDescriptor

the type descriptor of the field we are converting to

Returns:boolean

true if conversion should be performed, false otherwise