- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
public class DaoFactory {
private Map<Class<?>, Class<?>> daos = null;
public DaoFactory() {
init();
}
private void init() {
this.daos = new HashMap<>();
this.daos.put(AllSettings.class, AllSettingsDao.class);
this.daos.put(ClientProfile.class, ClientProfileDao.class);
}
public EntityDao<?> getDao(Class<?> entityClass) {
EntityDao<?> dao = null;
try {
if(daos.containsKey(entityClass)) {
dao = (EntityDao<?>)daos.get(entityClass).newInstance();
}
} catch (Exception e) {
e.printStackTrace();
}
return dao;
}
}