getConvertibleTypes abstract method
A general-purpose converter that can convert between multiple source–target type pairs.
This interface allows conversion logic to be shared across multiple type mappings, and optionally exposes the set of convertible type pairs.
đź”§ Example:
class MyConverter implements PairedConverter {
@override
Set<ConvertiblePair> getConvertibleTypes() => {
ConvertiblePair(Class<String>(), Class<int>())
};
@override
Object? convert(Object? source, Class sourceType, Class targetType) {
if (source is String && targetType.getType() == int) {
return int.tryParse(source);
}
return null;
}
}
Returns the set of source–target type pairs that this converter supports.
Can be null if the converter is conditional or uses runtime logic instead.
Implementation
Set<ConvertiblePair>? getConvertibleTypes();