项目Lombok @Data注释是否创建了任何类型的构造函数? [英] Does the Project Lombok @Data annotation create a constructor of any kind?
问题描述
我有一个带有 @Data
注释的类,但我不确定是否生成了带参数的构造函数,或者是否只生成了构造函数的默认值(无参数) )来自vanilla Java。
I have a class with a @Data
annotation, but I'm not sure whether a constructor with arguments is generated or the only generated constructor is the default (no arguments) one from vanilla Java.
推荐答案
将生成 @RequiredArgsConstructor
如果没有定义构造函数。
A @RequiredArgsConstructor
will be generated if no constructor has been defined.
@Data就像隐含@Getter,@ Setter,@ ToTtring,@ EqualsAndHashCode和类上的 @RequiredArgsConstructor 注释(如果存在任何显式编写的构造函数,则不会生成构造函数)。
@Data is like having implicit @Getter, @Setter, @ToString, @EqualsAndHashCode and @RequiredArgsConstructor annotations on the class (except that no constructor will be generated if any explicitly written constructor exists).
这篇关于项目Lombok @Data注释是否创建了任何类型的构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!