I have a simple problem try to stay DRY using Appengine.
The 2 functions below are identical except for the object sent as parameter. In reality I have 15 functions like this. I am try to find a way to create a super class or a generic to achieve this.
public void deleteRecord(Person s) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Person p = pm.getObjectById(Person.class, s.getId());
pm.deletePersistent(p);
} finally {
pm.close();
}
}
and
public void deleteRecord(Product s) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Product p = pm.getObjectById(Product.class, s.getId());
pm.deletePersistent(p);
} finally {
pm.close();
}
}
Unfortunately it seems that I cannot use generics since generics don't support T.class.
Any good suggestion how to do this w/o duplicating?
Thank you. Daniel