3 Replies Latest reply on Apr 27, 2015 3:35 PM by George Gastaldi

    Creating a static nested class using Roaster API

    Neil Stevens Newbie

      Hi,

       

      I'm using Roaster API to generate some Java source files.  I would like my Java source files to contain a nested static class like:

       

      class A {

           static class B {}

      }

       

      But I can't figure out how to get Roaster to generate this.  I can do the following to generate a non-static nested class:

       

      JavaClassSource aClass = Roaster.create(JavaClassSource.class);

      aClass.setName("A");

      JavaClassSource bClass = Roaster.create(JavaClassSource.class);

      bClass.setName("B");

      aClass.addNestedType(b);

       

      When adding a method to a class I can chain ".setStatic(true)" onto the addMethod method like:

      aClass.addMethod()

       

      aClass.addMethod().setStatic(true)..........

       

      But I can't chain "setStatic(true)" this with a nested class.  Does any any one know how to do this or if it is possible with Roaster API?