Guys, I'm not getting the list mails on my email but I can see the messages on the web (http://lists.jboss.org/pipermail/forge-users), so I'm re-posting George's answer:


Much better now, thank you very much George!
You can use the "resolveType" method to resolve the FQN:

JavaClassSource source = Roaster
         .parse(JavaClassSource.class,
                   "import foo.bar.Talk;"
                  + ""
                  + "public class TalkService extends
CrudService<Talk, Long> {}");

String superType = source.getSuperType();
String firstType = Types.splitGenerics(superType)[0];
String resolvedType = source.resolveType(firstType);
System.out.println(resolvedType);// Returns "foo.bar.Talk"

Best Regards,


George Gastaldi

Em sáb, 9 de mar de 2019 às 17:01, Rafael Pestano <rmpestano@gmail.com> escreveu:
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"));




 
--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
@realpestano
--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano