简体   繁体   中英

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>

我找到了这个解决方案

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM