I am trying to write a generic Converter to be used in multiple similar cases in my code. I have a set of subclasses that I want to handle using only one Converter, so I want to pass something (class type / some parameter / etc) to the Converter to be able to define
public class GenericConverter implements AttributeConverter<MyGenericClass , Integer> {
.
.
.
public MyGenericClass convertToEntityAttribute(Integer arg0) {
// return a certain sub class here according to an attribute / an initialization method / etc
}
and in the entities:
@Convert( converter = GenericConverter.class \*pass something here\* )
protected SubClass1 var1;
@Convert( converter = GenericConverter.class \*pass something here\* )
protected SubClass2 var2;
@Convert( converter = GenericConverter.class, \*pass something here\* )
protected SubClass3 var3;
Is this doable by any means?