[forge-users] Roaster - how to get superClass typeArgments
Rafael Pestano
rmpestano at gmail.com
Sat Mar 9 15:01:11 EST 2019
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
http://rpestano.wordpress.com/
@realpestano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-users/attachments/20190309/df7ee036/attachment.html
More information about the forge-users
mailing list