Generics in generator template

Hello,

in the generator I want to create an interface root template, which uses generics in method headers. The generated Java code of the method should look something like this:

<C extends SomeJavaClass> void doSomething(C someParameter);

I struggle to get the

<C extends SomeJavaClass>

part into the template. Is there a way to do this? Or should I try to use a different approach?

 

Thanks in advance.

2 comments
Comment actions Permalink

Ok... usually you would be able to accomplish this. But sometimes, it is hard to use the editors accordingly:

  1. Open the sample Project crossModelGeneration
  2. Go to the root mapping rule in the generator of Entities language: http://127.0.0.1:63320/node?ref=r%3A5cdac49d-a88c-42da-8dac-b7393c298671%28main%40generator%29%2F4053600266038198027&project=crossModelGeneration
  3. Add a new root mapping rule for Entity
  4. Use an interface to create the template
  5. In the freshly created root mapping add a method declaration to the interface.
  6. On the method name ALT+Enter choose: add Type Variable
  7. Type in C,  "space", "extends", the class name you want. 

 

1
Comment actions Permalink

That's it. Thanks a lot.

0

Please sign in to leave a comment.