Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using validation and other annotations on Lombok annotations

Is it possible to using other annotations on Lombok annotations?

Let's say have field Name and want to make sure it's not null when it's set using annotations.

Before 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 it's very simple example but is something like this possible?

like image 824
Droid_Interceptor Avatar asked Apr 23 '14 09:04

Droid_Interceptor


1 Answers

From Lombok documentation:

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

but, at the moment this is an experimental feature, You should read more on this topic

like image 189
endriu_l Avatar answered Sep 28 '22 06:09

endriu_l