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