Hi,
in forge is possibile to specify a superType class with generics? How to do this?
My use case is as follows: i have an entity bean, a repository session bean and an abstract class to extend.
1) An abstract repository with all persistence management functionality:
public abstract class AbstractRepository<T> implements Serializable {
public T find(Object key) {
try {
return getEm().find(getEntityType(), key);
} catch (Exception e) {return null; }
}
}
2) an entity class like:
@Entity
public class SImpleEntity implements Serializable {
private String name;
public String getName() {return name;}
public void setName(String name) {
this.name = name;}
}
3) i want to create a specific SImpleEntityRepository like:
@Stateless
@LocalBean
public class SImpleEntityRepository extends BaseRepository<SImpleEntity> {}
In ejb plugin i need to do this, to create a "add-extends" command (also for "add-implements").
My initial reasoning is this:
- read with reflection the super class, to understand if this class use generics.
- If the super class is like public abstract class AbstractRepository<T>{}:
i need to modify my current class (an ejb) specifying:
- or the generic class
- or asking to the user what's the real class to use.
But in forge, I can't do this:
JavaClass javaClass = JavaParser.create(JavaClass.class);
javaClass.setName("FlowerTest");
javaClass.setPackage("it.coopservice.test");
javaClass.addImport("org.jboss.forge.spec.ejb.testClasses.BaseEntity");
javaClass.addImport("org.jboss.forge.spec.ejb.testClasses.BaseRepositoryMultiVar");
javaClass.setSuperType("BaseRepositoryMultiVar<BaseEntity>");
Some trick for this?
Fiorenzo