I have below class Structure:
public class MyClass {}
public class AnotherClass {}
public class YetAnotherClass {}
@Component
public class MyFieldSetMapper extends BeanWrapperFieldSetMapper<MyClass>{
public MyFieldSetMapper() {
setTargetType(MyClass.class);
}
}
and I need to autowire the class in another class, The problem here is that I have to autowire a lot of MyFieldSetMapper types, i.e.
@Component
public class AnotherFieldSetMapper extends BeanWrapperFieldSetMapper<AnotherClass>{
public AnotherFieldSetMapper() {
setTargetType(AnotherClass.class);
}
}
and for yet another FieldSetMapperClass I have to dot this:
@Component
public class YetAnotherFieldSetMapper extends BeanWrapperFieldSetMapper<YetAnotherClass>{
public AnotherFieldSetMapper1() {
setTargetType(YetAnotherClass.class);
}
}
and I am duplicating a lot of code writing a new field set mapper every time I have a need of new mapper and I hate It. Could anyone please suggest me a much smarter/better code?