public interface MyMapperInterface<Y, Z> {
Y map(Z zObject);
}
public class One{
}
public class Two{
}
public MapperOneTwo implements MyMapperInterface<One, Two> {
public One map(Two twoObject){
//Based on properties of Two, a new One Object is created and returned.
}
}
public MapperThreeFour implements MyMapperInterface<Three, Four> {
public One map(Two twoObject){
//Now for two other class, Three and Four, there is a new
mapper.
Based on properties of Two, a new One Object is created and
returned.
}
}
FactoryClass
public class Factory {
public <T> T getClassInstance(String params){
if (params.equals("a")) {
return (T) new MapperOneTwo();
} else if (params.equals("b")){
return (T) new MapperThreeFour();
}
}
}
public interface MyMapperInterface<Y, Z> {