是否可以在 Lombok 注释上使用其他注释?
假设有一个字段名称,并希望确保它在使用注释设置时不为空。
Lombok 之前
public class Person(){
String name;
@NotNull
public void setName(String newName){
name = newName;
}
}
Lombok 之后
public class Person(){
@NotNull
@Setter
String name;
}
我知道这是一个非常简单的例子,但这样的事情可能吗?
最佳答案
来自 Lombok documentation :
To put annotations on the generated method, you can use onMethod=@__({@AnnotationsHere});
但是,目前这是一项实验性功能,您应该 read more关于这个话题
关于java - 在 Lombok 注释上使用验证和其他注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23240149/