我的java代码中包含以下类:
public abstract class DtoMapper< K, V > {
public abstract T map(K input);
}
在DtoMapper
@Component
public class RequestDtoMapper < TestA, TestB> extends DtoMapper < TestA, RequestDto, TestB> {
private Object input;
public RequestDtoMapper(TestA key,TestB key2){
if(key instanceof TestA){
input = (TestA)key;
}else
input = (TestB) key2;
}
}
@Override
public RequestDto **map(Object input)** {
//some code here
}
那么有什么方法可以在运行时动态地使类型为TestA
或TestB
的输入参数?