Using validation and other annotations on Lombok annotations

Can I use other annotations for Lombok annotations?

Suppose you have a Name field and want to make sure that it is not null when specified using annotations.

To Lombok

public class Person(){
     String name;

     @NotNull
     public void setName(String newName){
             name = newName;
     }
   }

After lombok

public class Person(){
     @NotNull
     @Setter
     String name;
   }

I know this is a very simple example, but is something like this possible?

+4
source share
1 answer

From Lombok documentation :

To add annotations to the generated method, you can use onMethod = @__ ({@AnnotationsHere});

but at the moment this is an experimental feature, you should read further in this section

+4
source

Source: https://habr.com/ru/post/1537670/


All Articles