Sunday, April 3, 2011

Write Java Method Signature with Annotated paramaters with JDT

Hi,

I am writing an eclipse plug-in which generates code. I am leveraging eclipse jdt to gen out classes, fields, and methods. One of the requirements I have is to generate methods with annotated paramaters...

public returnType foo(@someAnnotation int id)
{
     .....
     .....
}

Does anybody know how to write out the @someAnnotation using JDT? To write out normal parameters in JDT you could do something like the following

Signature.createTypeSignature("int", false)
From stackoverflow
  • Have you tried debugging the creation of a type signature with an annotation and inspect the parameters passed to createTypeSignature?

  • Hi, Yes I have tried this. The createTypeSignature() function does validation on the String that is passed to it. When it sees something like the following it throws an exception...

    Signature.createTypeSignature("@PathParam(\"custId\") int");
    

    Hope this clears it up, and thanks for the response. Let me know if you have any other ideas.

0 comments:

Post a Comment