Hi guys,
I have the following class:
public class TalkService extends CrudService<Talk, Long> ...
and I need to get the JavaClassSource of the first superClass type argment (Talk).
The only way I've found was to get the type argument name and then find the entity by looking at the imports but I wonder if there's a simpler way:
JavaClassSource service = Roaster.parse....
String entityName = service.getSuperType().substring(service.getSuperType().indexOf("<")+1,service.getSuperType().indexOf(","));
Optional<Import> entityImport = service.getImports().stream().filter(i -> i.getQualifiedName().endsWith(entityName))
.findFirst();
String entityQualifiedName = entityImport.get().getQualifiedName();
String sourceFolder = sourceFacet.getSourceDirectory().getFullyQualifiedName();
JavaClassSource entity = Roaster.parse(JavaClassSource.class, new File(sourceFolder + "/" + entityQualifiedName.replace(".", "/") + ".java"));
--