Is it possible to Trigger Custom Created Converter with annotation.
1) Annotation Class:
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Component
public @interface Currency{
String sourceType();
String targetType();
}
2)Custom Converter:
@Component
public class CurrencyConverter implements Converter<Long, Long>{
@Override
public Long convert(Long source) {
return Long.valueOf(source*2); //any Logic
}
}
3) web MVC Config : Register Converter
@Override
public void addFormatters (FormatterRegistry registry) {
registry.addConverter(new CurrencyConverter());
}
I want to invoke my custom Converter for my annotated Class.
Aucun commentaire:
Enregistrer un commentaire