项目Lombok @Data注释是否创建了任何类型的构造函数? [英] Does the Project Lombok @Data annotation create a constructor of any kind?

查看:8881
本文介绍了项目Lombok @Data注释是否创建了任何类型的构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 @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.

项目Lombok @Data页面解释:


@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆