1 Reply Latest reply on Mar 11, 2016 10:50 PM by gastaldi

    Roaster: How do you retrieve fields and methods of an inner class

    johnc_thatsme

      I am trying to alter some jaxb generated source code so that it will also follow the conventions of an ORM mapper.  One task in that process is to add setter methods to expose the list to any class that contains a List field.  (JAXB only provides a getter method)

       

      I have been able to retrieve fields on existing top level classes by invoking the getFields() method on a JavaClassSource.

       

      JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File("/path/to/SomeClass.java"));

      List<FieldSource<JavaClassSource>> fields = javaClass.getFields();

      ..

       

      But I haven't been able to figure out how to similar to the inner classes of the same declaring class, as getFields() is not exposed in JavaSource.

       

      List<JavaSource<?>> nestedClasses = javaClass.getNestedTypes();

      for (JavaSource<?> nestedClass : nestedClasses) {

           List<FieldSource<JavaClassSource>> fields = nestedClass.getFields(); // this does not exist

           ..

      }    

       

      Is there a way to do what I want to do?