0
public class DAOHelper {
private static final Map<Class, Class> DTO_TO_DAO_MAP;
private static final Map<Class, Class> ACDTO_TO_ACDAO_MAP;
static {
DTO_TO_DAO_MAP = new HashMap<Class, Class>();
DTO_TO_DAO_MAP.put(EmployerDTO.class, EmployerDAO.class);
ACDTO_TO_ACDAO_MAP = new HashMap<Class, Class>();
ACDTO_TO_ACDAO_MAP.put(AcademicDTO.class, AcademicDAO.class);
}
public static BaseDAO<?> getDAO(Class dtoClass) {
BaseDAO<?> dao = null;
Class daoClass = ACDTO_TO_ACDAO_MAP.get(dtoClass); //here
//rest of code here
}
Class daoClass = ACDTO_TO_ACDAO_MAP.get(dtoClass);
自動檢測在代碼這一比例,而不是ACDTO_TO_ACDAO_MAP
我怎麼能得到的代碼自動檢測這一點,所以我不會爲每一個做手工,因爲它可以DTO_TO_DAO_MAP
或他人...正確的地圖