Search code examples
javaannotationscode-injectionlombok

Generate code with specific type element on Lombok


I want to add a costume annotation on lombok to Generate another variable from one variable.

I want to create an annotation with a Lombok This annotation @selectOne :

   @selectOne
    Private String client;

Now I want to add automatically variable who inject this code :

Private String client;
List <String> listClient;
List <String> selectClient;

It don't work when I add a type Element type variable to a List but it work when it like this :

Private String client;
List  listClient;
List selectClient;

On lombok i used this code to generate variables:

JavacNode node;
JCExpression    typeList =chainDots(node, "java", "util", "List");
this variable typeList type java.util.List

and I want that typeList be a java.util.List<String>


Solution

  • I had found this solution

    JCExpression testDeclarList =maker.TypeApply(chainDotsString(fieldNode, "java.util.List"), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "String")));