{"id":2017,"date":"2023-04-01T19:15:04","date_gmt":"2023-04-01T11:15:04","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2017"},"modified":"2023-04-07T10:36:44","modified_gmt":"2023-04-07T02:36:44","slug":"lombok-usage-details","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/lombok-usage-details\/","title":{"rendered":"Lombok\u4f7f\u7528\u8be6\u89e3"},"content":{"rendered":"<h2>Lombok\u7b80\u4ecb<\/h2>\n<p>Lombok\u662f\u4e00\u4e2a\u53ef\u4ee5\u901a\u8fc7\u6ce8\u89e3\u6765\u5e2e\u52a9\u6211\u4eec\u7b80\u5316\u6d88\u9664\u4e00\u4e9b\u5fc5\u987b\u6709\u4f46\u663e\u5f97\u5f88\u81c3\u80bf\u7684Java\u4ee3\u7801\u7684\u4e00\u79cd\u5de5\u5177\uff0c\u901a\u8fc7\u4f7f\u7528\u5bf9\u5e94\u7684\u6ce8\u89e3\uff0c\u53ef\u4ee5\u5728\u7f16\u8bd1\u6e90\u7801\u7684\u65f6\u5019\u52a8\u6001\u6dfb\u52a0\u6e90\u7801\u3002<\/p>\n<p><!-- more --><\/p>\n<p>\u4f8b\u5982\u5728\u5b9e\u4f53\u4e2d\u7ecf\u5e38\u89c1\u5230\u4e00\u5806Getter\u548cSetter\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u662f\u5fc5\u8981\u7684\u4e0d\u53ef\u7f3a\u5c11\u7684\uff0c\u4f46\u662f\u8fd9\u4e9b\u4ee3\u7801\u611f\u89c9\u5374\u50cf\u662f\u201c\u5783\u573e\u201d\uff0c\u770b\u8d77\u6765\u91cd\u590d\u800c\u81c3\u80bf\uff0c\u4e5f\u4e0d\u7f8e\u89c2\uff0c\u53ef\u4ee5\u4f7f\u7528Lombok\uff0c\u5728\u7c7b\u4e0a\u76f4\u63a5\u4f7f\u7528<code>@Getter<\/code>\u548c<code>@Setter<\/code>\u8fd9\u4e24\u4e2a\u6ce8\u89e3\uff0c\u90a3\u4e48\u4ee3\u7801\u5728\u7f16\u8bd1\u65f6\u4f1a\u81ea\u52a8\u5e2e\u4f60\u751f\u6210\u8fd9\u4e2a\u7c7b\u4e0b\u7684\u6240\u6709\u5b57\u6bb5\u5bf9\u5e94\u7684Getter\u548cSetter\u65b9\u6cd5\uff0c\u5b9e\u4f53\u4e2d\u53ea\u6709\u4e00\u4e9b\u5c5e\u6027\uff0c\u770b\u8d77\u6765\u5b9e\u4f53\u7c7b\u53d8\u5f97\u7b80\u6d01\u5f88\u591a\u3002\u867d\u7136IDE\u53ef\u4ee5\u5f88\u5feb\u7684\u751f\u6210\u51fa\u6765\uff0c\u4f46\u662f\u751f\u6210\u4e4b\u540e\u7684\u5b9e\u4f53\u8fd8\u662f\u90a3\u4e48\u7684\u81c3\u80bf\uff0c\u800c\u4e14\u5982\u679c\u4fee\u6539\u4e86\u5b57\u6bb5\u7684\u540d\u79f0\u6216\u8005\u5b57\u6bb5\u7684\u7c7b\u578b\u8fd8\u8981\u91cd\u65b0\u751f\u6210\uff0c\u6bd4\u8f83\u9ebb\u70e6\uff0c\u4f7f\u7528Lombok\u5c31\u662f\u6d88\u9664\u4e00\u4e9b\u542b\u91d1\u91cf\u4e0d\u9ad8\u5374\u5fc5\u987b\u8981\u6709\u7684\u4ee3\u7801\uff0c\u4f7f\u7a0b\u5e8f\u5458\u770b\u8d77\u6765\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u3001\u6e05\u723d\u3002<\/p>\n<blockquote>\n<p>Automatic Resource Management, automatic generation of getters, setters, equals, hashCode and toString, and more!<\/p>\n<\/blockquote>\n<p>Lombok\u7684\u5b98\u65b9\u5730\u5740\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/projectlombok.org\/\">https:\/\/projectlombok.org\/<\/a><br \/>\nLombok\u7684Github\u5730\u5740\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/rzwitserloot\/lombok\">https:\/\/github.com\/rzwitserloot\/lombok<\/a><\/p>\n<h2>Lombok plugin \u63d2\u4ef6<\/h2>\n<p>Intellij Idea\u4f7f\u7528Lombok\u9700\u8981\u5b89\u88c5\u63d2\u4ef6\uff1aLombok plugin<\/p>\n<p><code>Preferences<\/code> \u2014&gt; <code>Plugins<\/code> \u2014&gt; \u641c\u7d22 <code>Lombok plugin<\/code> \u2014 &gt; <code>Install<\/code><\/p>\n<p>\u540c\u65f6\u8bbe\u7f6e<code>Preferences<\/code> -&gt; <code>Compiler<\/code> -&gt; <code>Annotation Processors<\/code> -&gt; <code>Enable annotation processing<\/code>\u52fe\u9009<\/p>\n<h2>\u4f7f\u7528\u793a\u4f8b<\/h2>\n<p>\u9996\u5148\u5f15\u5165Lombok\u4f9d\u8d56<\/p>\n<pre><code class=\"language-xml\">&lt;!-- https:\/\/mvnrepository.com\/artifact\/org.projectlombok\/lombok --&gt;\n&lt;dependency&gt;\n    &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;\n    &lt;artifactId&gt;lombok&lt;\/artifactId&gt;\n    &lt;version&gt;1.18.6&lt;\/version&gt;\n    &lt;scope&gt;provided&lt;\/scope&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<h3>@Getter\/@Setter<\/h3>\n<p>\u4e3a\u5b57\u6bb5\u751f\u6210Getter\u548cSetter\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6ce8\u89e3\u5230\u5b57\u6bb5\u6216\u8005\u7c7b\u4e0a(\u6ce8\u89e3\u5728\u7c7b\u4e0a\u4f1a\u4e3a\u7c7b\u4e2d\u7684\u6240\u6709\u5b57\u6bb5\u751f\u6210Getter\u548cSetter\u65b9\u6cd5)\uff0c\u9ed8\u8ba4\u662fpublic\u7c7b\u578b\u7684\uff0c\u5982\u679c\u9700\u8981\u7684\u8bdd\u53ef\u4ee5\u4fee\u6539\u65b9\u6cd5\u7684\u8bbf\u95ee\u7ea7\u522b\u3002<\/p>\n<pre><code class=\"language-java\">public class User {\n    @Getter @Setter\n    private Long id;\n\n    @Getter(AccessLevel.PROTECTED)\n    private String phone;\n\n    private String password;\n}<\/code><\/pre>\n<p>\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n    private String password;\n\n    public User() {\n    }\n\n    public Long getId() {\n        return this.id;\n    }\n\n    public void setId(Long id) {\n        this.id = id;\n    }\n\n    protected String getPhone() {\n        return this.phone;\n    }\n}<\/code><\/pre>\n<p>\u7ed3\u679c\u89e3\u91ca\uff1a<\/p>\n<ul>\n<li><code>id<\/code>\u5b57\u6bb5\u751f\u6210\u4e86<code>Getter<\/code>&amp;<code>Setter<\/code>\uff0c\u8bbf\u95ee\u4fee\u9970\u7b26\u662f<code>public<\/code><\/li>\n<li><code>phone<\/code>\u53ea\u751f\u6210\u4e86<code>Getter<\/code>\u65b9\u6cd5\uff0c\u56e0\u4e3a\u53ea\u4f7f\u7528\u4e86<code>@Getter<\/code>\u800c\u6ca1\u6709\u4f7f\u7528<code>@Setter<\/code>, \u5e76\u4e14\u8bbf\u95ee\u4fee\u9970\u7b26\u662f<code>protected<\/code><\/li>\n<li><code>password<\/code>\u4e0a\u5e76\u6ca1\u6709\u6ce8\u89e3\uff0c\u6240\u4ee5\u4ec0\u4e48\u90fd\u4e0d\u751f\u6210<\/li>\n<\/ul>\n<blockquote>\n<p>\u6ce8\u610f\uff1aLombok\u4e2d\u7684\u6ce8\u89e3\u4e00\u822c\u90fd\u4f1a\u5305\u542b\u4e00\u4e2a\u65e0\u53c2\u6784\u9020\u51fd\u6570\u6ce8\u89e3<code>@NoArgsConstructor<\/code>(\u7528\u4e8e\u751f\u6210\u65e0\u53c2\u6784\u9020\u51fd\u6570\u7684)\uff0c\u6240\u4ee5\u8fd8\u4f1a\u989d\u5916\u751f\u6210\u4e00\u4e2a\u65e0\u53c2\u6784\u9020\u51fd\u6570<\/p>\n<\/blockquote>\n<p>@Getter @Setter \u6ce8\u89e3\u5728\u7c7b\u4e0a\uff0c\u8868\u793a\u4e3a\u7c7b\u4e2d\u7684\u6240\u6709\u5b57\u6bb5\u751f\u6210<code>Getter<\/code>&amp;<code>Setter<\/code>\u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"language-java\">@Getter @Setter\npublic class User {\n    private Long id;\n    private String phone;\n    private String password;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n    private String password;\n\n    public User() {\n    }\n\n    public Long getId() {\n        return this.id;\n    }\n\n    public String getPhone() {\n        return this.phone;\n    }\n\n    public String getPassword() {\n        return this.password;\n    }\n\n    public void setId(Long id) {\n        this.id = id;\n    }\n\n    public void setPhone(String phone) {\n        this.phone = phone;\n    }\n\n    public void setPassword(String password) {\n        this.password = password;\n    }\n}<\/code><\/pre>\n<h3>@NonNull<\/h3>\n<p>\u4e3a\u5b57\u6bb5\u8d4b\u503c\u65f6(\u5373\u8c03\u7528\u5b57\u6bb5\u7684<code>Setter<\/code>\u65b9\u6cd5\u65f6)\uff0c\u5982\u679c\u4f20\u7684\u53c2\u6570\u4e3anull\uff0c\u5219\u4f1a\u629b\u51fa\u7a7a\u5f02\u5e38<code>NullPointerException<\/code>\uff0c\u751f\u6210<code>Setter<\/code>\u65b9\u6cd5\u65f6\u4f1a\u5bf9\u53c2\u6570\u662f\u5426\u4e3a\u7a7a\u68c0\u67e5<\/p>\n<pre><code class=\"language-java\">@Getter\n@Setter\npublic class User {\n    private Long id;\n\n    @NonNull\n    private String phone;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    @NonNull\n    private String phone;\n\n    public User() {\n    }\n\n    public Long getId() {\n        return this.id;\n    }\n    public void setId(Long id) {\n        this.id = id;\n    }\n    @NonNull\n    public String getPhone() {\n        return this.phone;\n    }\n\n    public void setPhone(@NonNull String phone) {\n        if(phone == null) {\n            throw new NullPointerException(&quot;phone&quot;);\n        } else {\n            this.phone = phone;\n        }\n    }\n}<\/code><\/pre>\n<h3>@NoArgsConstructor<\/h3>\n<p>\u751f\u6210\u4e00\u4e2a\u65e0\u53c2\u6784\u9020\u65b9\u6cd5\u3002\u5f53\u7c7b\u4e2d\u6709final\u5b57\u6bb5\u6ca1\u6709\u88ab\u521d\u59cb\u5316\u65f6\uff0c\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\uff0c\u6b64\u65f6\u53ef\u7528<code>@NoArgsConstructor(force = true)<\/code>\uff0c\u7136\u540e\u5c31\u4f1a\u4e3a\u6ca1\u6709\u521d\u59cb\u5316\u7684final\u5b57\u6bb5\u8bbe\u7f6e\u9ed8\u8ba4\u503c<code>0 \/ false \/ null<\/code>\uff0c\u8fd9\u6837\u7f16\u8bd1\u5668\u5c31\u4e0d\u4f1a\u62a5\u9519\u3002\u5bf9\u4e8e\u5177\u6709\u7ea6\u675f\u7684\u5b57\u6bb5\uff08\u4f8b\u5982<code>@NonNull<\/code>\u5b57\u6bb5\uff09\uff0c\u4e0d\u4f1a\u751f\u6210\u68c0\u67e5\u6216\u5206\u914d\uff0c\u56e0\u6b64\u8bf7\u6ce8\u610f\uff0c\u6b63\u786e\u521d\u59cb\u5316\u8fd9\u4e9b\u5b57\u6bb5\u4e4b\u524d\uff0c\u8fd9\u4e9b\u7ea6\u675f\u65e0\u6548\u3002<\/p>\n<pre><code class=\"language-java\">@NoArgsConstructor(force = true)\npublic class User {\n    private Long id;\n\n    @NonNull\n    private String phone;\n\n    private final Integer age;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    @NonNull\n    private String phone;\n    private final Integer age = null;\n\n    public User() {\n    }\n}<\/code><\/pre>\n<h3>@RequiredArgsConstructor<\/h3>\n<p>\u751f\u6210\u6784\u9020\u65b9\u6cd5\uff08\u53ef\u80fd\u5e26\u53c2\u6570\u4e5f\u53ef\u80fd\u4e0d\u5e26\u53c2\u6570\uff09\uff0c\u5982\u679c\u5e26\u53c2\u6570\uff0c\u8fd9\u53c2\u6570\u53ea\u80fd\u662f\u4ee5final\u4fee\u9970\u7684\u672a\u7ecf\u521d\u59cb\u5316\u7684\u5b57\u6bb5\uff0c\u6216\u8005\u662f\u4ee5<code>@NonNull<\/code>\u6ce8\u89e3\u7684\u672a\u7ecf\u521d\u59cb\u5316\u7684\u5b57\u6bb5\u3002<\/p>\n<p><code>@RequiredArgsConstructor(staticName = &quot;of&quot;)<\/code>\u4f1a\u751f\u6210\u4e00\u4e2a<code>of()<\/code>\u7684\u9759\u6001\u65b9\u6cd5\uff0c\u5e76\u628a\u6784\u9020\u65b9\u6cd5\u8bbe\u7f6e\u4e3a\u79c1\u6709\u7684<\/p>\n<pre><code class=\"language-java\">@RequiredArgsConstructor\npublic class User {\n    private Long id;\n\n    @NonNull\n    private String phone;\n\n    @NotNull\n    private Integer status = 0;\n\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    @NonNull\n    private String phone;\n    @NotNull\n    private Integer status = Integer.valueOf(0);\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n\n    public User(@NonNull String phone, Integer age) {\n        if(phone == null) {\n            throw new NullPointerException(&quot;phone&quot;);\n        } else {\n            this.phone = phone;\n            this.age = age;\n        }\n    }\n}<\/code><\/pre>\n<p>\u5fc5\u8981\u7684\u6784\u9020\u51fd\u6570\u53ea\u4f1a\u751f\u6210<code>final<\/code>\u4fee\u9970\u7684\u672a\u7ecf\u521d\u59cb\u5316\u7684\u5b57\u6bb5\u6216\u8005\u662f\u4ee5<code>@NonNull<\/code>\u6ce8\u89e3\u7684\u672a\u7ecf\u521d\u59cb\u5316\u7684\u5b57\u6bb5\uff0c\u6240\u4ee5\u751f\u6210\u4e86<code>public User(@NonNull String phone, Integer age)<\/code>\u6784\u9020\u51fd\u6570<\/p>\n<pre><code class=\"language-java\">@RequiredArgsConstructor(staticName = &quot;of&quot;)\npublic class User {\n    private Long id;\n\n    @NonNull\n    private String phone;\n\n    @NotNull\n    private Integer status = 0;\n\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    @NonNull\n    private String phone;\n    @NotNull\n    private Integer status = Integer.valueOf(0);\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n\n    private User(@NonNull String phone, Integer age) {\n        if(phone == null) {\n            throw new NullPointerException(&quot;phone&quot;);\n        } else {\n            this.phone = phone;\n            this.age = age;\n        }\n    }\n\n    public static User of(@NonNull String phone, Integer age) {\n        return new User(phone, age);\n    }\n}<\/code><\/pre>\n<h3>@AllArgsConstructor<\/h3>\n<p>\u751f\u6210\u4e00\u4e2a\u5168\u53c2\u6570\u7684\u6784\u9020\u65b9\u6cd5\uff0c\u53ea\u4e0d\u5305\u62ec<code>final<\/code>\u4fee\u9970\u7684\u4e14\u7ecf\u521d\u59cb\u5316\u7684\u5b57\u6bb5<\/p>\n<pre><code class=\"language-java\">@AllArgsConstructor\npublic class User {\n    private Long id;\n\n    @NonNull\n    private String phone;\n\n    @NotNull\n    private Integer status = 0;\n\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    @NonNull\n    private String phone;\n    @NotNull\n    private Integer status = Integer.valueOf(0);\n    private final Integer age;\n    private final String country = &quot;china&quot;;\n\n    public User(Long id, @NonNull String phone, Integer status, Integer age) {\n        if(phone == null) {\n            throw new NullPointerException(&quot;phone&quot;);\n        } else {\n            this.id = id;\n            this.phone = phone;\n            this.status = status;\n            this.age = age;\n        }\n    }\n}<\/code><\/pre>\n<h3>@ToString<\/h3>\n<p>\u751f\u6210toString()\u65b9\u6cd5\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5b83\u4f1a\u6309\u987a\u5e8f\uff08\u4ee5\u9017\u53f7\u5206\u9694\uff09\u6253\u5370\u4f60\u7684\u7c7b\u540d\u79f0\u4ee5\u53ca\u6bcf\u4e2a\u5b57\u6bb5\u3002\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e\u4e0d\u5305\u542b\u54ea\u4e9b\u5b57\u6bb5\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u4e5f\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a<code>@ToString(exclude = &quot;id&quot;)<\/code> \/ <code>@ToString(exclude = {&quot;id&quot;, &quot;name&quot;})<\/code><\/p>\n<p>\u5982\u679c\u7ee7\u627f\u7684\u6709\u7236\u7c7b\u7684\u8bdd\uff0c\u53ef\u4ee5\u8bbe\u7f6e<code>callSuper<\/code>\u8ba9\u5176\u8c03\u7528\u7236\u7c7b\u7684toString()\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<code>@ToString(callSuper = true)<\/code><\/p>\n<pre><code class=\"language-java\">@ToString(exclude = {&quot;password&quot;, &quot;salt&quot;})\npublic class User {\n\n    private Long id;\n\n    private String phone;\n\n    private String password;\n\n    private String salt;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n    private String password;\n    private String salt;\n\n    public User() {\n    }\n\n    public String toString() {\n        return &quot;User(id=&quot; + this.id + &quot;, phone=&quot; + this.phone + &quot;)&quot;;\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">@ToString(exclude = {&quot;password&quot;, &quot;salt&quot;}, callSuper = true)\npublic class User {\n\n    private Long id;\n\n    private String phone;\n\n    private String password;\n\n    private String salt;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n    private String password;\n    private String salt;\n\n    public User() {\n    }\n\n    public String toString() {\n        return &quot;User(super=&quot; + super.toString() + &quot;, id=&quot; + this.id + &quot;, phone=&quot; + this.phone + &quot;)&quot;;\n    }\n}<\/code><\/pre>\n<h3>@EqualsAndHashCode<\/h3>\n<p>\u751f\u6210<code>hashCode()<\/code>\u548c<code>equals()<\/code>\u65b9\u6cd5\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u5c06\u4f7f\u7528\u6240\u6709\u975e\u9759\u6001\uff0c\u975e<code>transient<\/code>\u5b57\u6bb5\u3002\u4f46\u53ef\u4ee5\u901a\u8fc7\u5728\u53ef\u9009\u7684<code>exclude<\/code>\u53c2\u6570\u4e2d\u6765\u6392\u9664\u66f4\u591a\u5b57\u6bb5\u3002\u6216\u8005\uff0c\u901a\u8fc7\u5728<code>of<\/code>\u53c2\u6570\u4e2d\u547d\u540d\u5b83\u4eec\u6765\u51c6\u786e\u6307\u5b9a\u5e0c\u671b\u4f7f\u7528\u54ea\u4e9b\u5b57\u6bb5\u3002<\/p>\n<pre><code class=\"language-java\">\/\/ exclude \u6392\u9664\u5b57\u6bb5\n@EqualsAndHashCode(exclude = {&quot;password&quot;, &quot;salt&quot;})\n\n\/\/ of \u6307\u5b9a\u8981\u5305\u542b\u7684\u5b57\u6bb5\n@EqualsAndHashCode(of = {&quot;id&quot;, &quot;phone&quot;, &quot;password&quot;})<\/code><\/pre>\n<pre><code class=\"language-java\">@EqualsAndHashCode\npublic class User implements Serializable{\n\n    private static final long serialVersionUID = 6569081236403751407L;\n\n    private Long id;\n\n    private String phone;\n\n    private transient int status;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User implements Serializable {\n    private static final long serialVersionUID = 6569081236403751407L;\n    private Long id;\n    private String phone;\n    private transient int status;\n\n    public User() {\n    }\n\n    public boolean equals(Object o) {\n        if(o == this) {\n            return true;\n        } else if(!(o instanceof User)) {\n            return false;\n        } else {\n            User other = (User)o;\n            if(!other.canEqual(this)) {\n                return false;\n            } else {\n                Long this$id = this.id;\n                Long other$id = other.id;\n                if(this$id == null) {\n                    if(other$id != null) {\n                        return false;\n                    }\n                } else if(!this$id.equals(other$id)) {\n                    return false;\n                }\n\n                String this$phone = this.phone;\n                String other$phone = other.phone;\n                if(this$phone == null) {\n                    if(other$phone != null) {\n                        return false;\n                    }\n                } else if(!this$phone.equals(other$phone)) {\n                    return false;\n                }\n\n                return true;\n            }\n        }\n    }\n\n    protected boolean canEqual(Object other) {\n        return other instanceof User;\n    }\n\n    public int hashCode() {\n        boolean PRIME = true;\n        byte result = 1;\n        Long $id = this.id;\n        int result1 = result * 59 + ($id == null?43:$id.hashCode());\n        String $phone = this.phone;\n        result1 = result1 * 59 + ($phone == null?43:$phone.hashCode());\n        return result1;\n    }\n}<\/code><\/pre>\n<p>\u751f\u6210\u4e86 equals \u3001hashCode \u548c canEqual \u65e0\u53c2\u6784\u9020\u51fd\u6570 \u56db\u4e2a\u65b9\u6cd5<\/p>\n<h3>@Data<\/h3>\n<p><code>@Data<\/code>\u5305\u542b\u4e86<code>@ToString<\/code>\u3001<code>@EqualsAndHashCode<\/code>\u3001<code>@Getter<\/code> \/ <code>@Setter<\/code>\u548c<code>@RequiredArgsConstructor<\/code>\u7684\u529f\u80fd<\/p>\n<pre><code class=\"language-java\">@Data\npublic class User {\n    private Long id;\n    private String phone;\n    private Integer status;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n    private Integer status;\n\n    public User() {\n    }\n\n    public Long getId() {\n        return this.id;\n    }\n\n    public String getPhone() {\n        return this.phone;\n    }\n\n    public Integer getStatus() {\n        return this.status;\n    }\n\n    public void setId(Long id) {\n        this.id = id;\n    }\n\n    public void setPhone(String phone) {\n        this.phone = phone;\n    }\n\n    public void setStatus(Integer status) {\n        this.status = status;\n    }\n\n    public boolean equals(Object o) {\n        if(o == this) {\n            return true;\n        } else if(!(o instanceof User)) {\n            return false;\n        } else {\n            User other = (User)o;\n            if(!other.canEqual(this)) {\n                return false;\n            } else {\n                label47: {\n                    Long this$id = this.getId();\n                    Long other$id = other.getId();\n                    if(this$id == null) {\n                        if(other$id == null) {\n                            break label47;\n                        }\n                    } else if(this$id.equals(other$id)) {\n                        break label47;\n                    }\n\n                    return false;\n                }\n\n                String this$phone = this.getPhone();\n                String other$phone = other.getPhone();\n                if(this$phone == null) {\n                    if(other$phone != null) {\n                        return false;\n                    }\n                } else if(!this$phone.equals(other$phone)) {\n                    return false;\n                }\n\n                Integer this$status = this.getStatus();\n                Integer other$status = other.getStatus();\n                if(this$status == null) {\n                    if(other$status != null) {\n                        return false;\n                    }\n                } else if(!this$status.equals(other$status)) {\n                    return false;\n                }\n\n                return true;\n            }\n        }\n    }\n\n    protected boolean canEqual(Object other) {\n        return other instanceof User;\n    }\n\n    public int hashCode() {\n        boolean PRIME = true;\n        byte result = 1;\n        Long $id = this.getId();\n        int result1 = result * 59 + ($id == null?43:$id.hashCode());\n        String $phone = this.getPhone();\n        result1 = result1 * 59 + ($phone == null?43:$phone.hashCode());\n        Integer $status = this.getStatus();\n        result1 = result1 * 59 + ($status == null?43:$status.hashCode());\n        return result1;\n    }\n\n    public String toString() {\n        return &quot;User(id=&quot; + this.getId() + &quot;, phone=&quot; + this.getPhone() + &quot;, status=&quot; + this.getStatus() + &quot;)&quot;;\n    }\n}<\/code><\/pre>\n<h3>@Value<\/h3>\n<p><code>@Value<\/code>\u5c06\u5b57\u6bb5\u90fd\u53d8\u6210\u4e0d\u53ef\u53d8\u7c7b\u578b\uff1a\u4f7f\u7528final\u4fee\u9970\uff0c\u540c\u65f6\u8fd8\u5305\u542b<code>@ToString<\/code>\u3001<code>@EqualsAndHashCode<\/code>\u3001<code>@AllArgsConstructor<\/code>\u3001<code>@Getter<\/code>(\u6ce8\u610f\u53ea\u6709Getter\u6ca1\u6709Setter)<\/p>\n<pre><code class=\"language-java\">@Value\npublic class User {\n    private Long id;\n    private String username;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public final class User {\n    private final Long id;\n    private final String username;\n\n    public User(Long id, String username) {\n        this.id = id;\n        this.username = username;\n    }\n\n    public Long getId() {\n        return this.id;\n    }\n\n    public String getUsername() {\n        return this.username;\n    }\n\n    public boolean equals(Object o) {\n        if(o == this) {\n            return true;\n        } else if(!(o instanceof User)) {\n            return false;\n        } else {\n            User other = (User)o;\n            Long this$id = this.getId();\n            Long other$id = other.getId();\n            if(this$id == null) {\n                if(other$id != null) {\n                    return false;\n                }\n            } else if(!this$id.equals(other$id)) {\n                return false;\n            }\n\n            String this$username = this.getUsername();\n            String other$username = other.getUsername();\n            if(this$username == null) {\n                if(other$username != null) {\n                    return false;\n                }\n            } else if(!this$username.equals(other$username)) {\n                return false;\n            }\n\n            return true;\n        }\n    }\n\n    public int hashCode() {\n        boolean PRIME = true;\n        byte result = 1;\n        Long $id = this.getId();\n        int result1 = result * 59 + ($id == null?43:$id.hashCode());\n        String $username = this.getUsername();\n        result1 = result1 * 59 + ($username == null?43:$username.hashCode());\n        return result1;\n    }\n\n    public String toString() {\n        return &quot;User(id=&quot; + this.getId() + &quot;, username=&quot; + this.getUsername() + &quot;)&quot;;\n    }\n}<\/code><\/pre>\n<h3>@Log<\/h3>\n<p>\u751f\u6210log\u5bf9\u8c61\uff0c\u7528\u4e8e\u8bb0\u5f55\u65e5\u5fd7\uff0c\u53ef\u4ee5\u901a\u8fc7topic\u5c5e\u6027\u6765\u8bbe\u7f6e<code>getLogger(String name)<\/code>\u65b9\u6cd5\u7684\u53c2\u6570 \u4f8b\u5982<code>@Log4j(topic = \u201ccom.xxx.entity.User\u201d)<\/code>\uff0c\u9ed8\u8ba4\u662f\u7c7b\u7684\u5168\u9650\u5b9a\u540d\uff0c\u5373 \u7c7b\u540d.class\uff0clog\u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n<pre><code class=\"language-java\">@Log java.util.logging.Logger\n@Log4j org.apache.log4j.Logger\n@Log4j2 org.apache.logging.log4j.Logger\n@Slf4j org.slf4j.Logger\n@XSlf4j org.slf4j.ext.XLogger\n@CommonsLog org.apache.commons.logging.Log\n@JBossLog org.jboss.logging.Logger<\/code><\/pre>\n<pre><code class=\"language-java\">@Log\n    private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());\n@Log4j\n    private static final Logger log = org.apache.log4j.Logger.Logger.getLogger(UserService.class);\n@Log4j2\n    private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LogExample.class);\n@Slf4j\n    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);\n@XSlf4j\n    private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LogExample.class);\n@CommonsLog\n    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class);\n@JBossLog\n    private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LogExample.class);<\/code><\/pre>\n<pre><code class=\"language-java\">@Log\npublic class UserService {\n\n    public void addUser() {\n        log.info(&quot;add user&quot;);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">import java.util.logging.Logger;\n\npublic class UserService {\n    private static final Logger log = Logger.getLogger(UserService.class.getName());\n\n    public UserService() {\n    }\n\n    public void addUser() {\n        log.info(&quot;add user&quot;);\n    }\n}<\/code><\/pre>\n<h3>@SneakyThrows<\/h3>\n<p>\u4f7f\u7528<code>try catch<\/code>\u6765\u6355\u83b7\u5f02\u5e38\uff0c\u9ed8\u8ba4\u6355\u83b7\u7684\u662f<code>Throwable<\/code>\u5f02\u5e38\uff0c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u8981\u6355\u83b7\u7684\u5f02\u5e38<\/p>\n<pre><code class=\"language-java\">public class User {\n\n    @SneakyThrows\n    public void sleep() {\n        Thread.sleep(1000);\n    }\n\n    @SneakyThrows(InterruptedException.class)\n    public void sleep2() {\n        Thread.sleep(1000);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    public User() {\n    }\n\n    public void sleep() {\n        try {\n            Thread.sleep(1000L);\n        } catch (Throwable var) {\n            throw var;\n        }\n    }\n\n    public void sleep2() {\n        try {\n            Thread.sleep(1000L);\n        } catch (InterruptedException var) {\n            throw var;\n        }\n    }\n}<\/code><\/pre>\n<h3>@Synchronized<\/h3>\n<p>\u7ed9\u65b9\u6cd5\u52a0\u4e0a\u540c\u6b65\u9501<\/p>\n<pre><code class=\"language-java\">public class User {\n    private final Object readLock = new Object();\n\n    @Synchronized\n    public static void foo() {\n        System.out.println();\n    }\n\n    @Synchronized\n    public void bar() {\n        System.out.println();\n    }\n\n    @Synchronized(&quot;readLock&quot;)\n    public void test() {\n        System.out.println();\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private static final Object $LOCK = new Object[0];\n    private final Object $lock = new Object[0];\n    private final Object readLock = new Object();\n\n    public User() {\n    }\n\n    public static void foo() {\n        Object var0 = $LOCK;\n        synchronized($LOCK) {\n            System.out.println();\n        }\n    }\n\n    public void bar() {\n        Object var1 = this.$lock;\n        synchronized(this.$lock) {\n            System.out.println();\n        }\n    }\n\n    public void test() {\n        Object var1 = this.readLock;\n        synchronized(this.readLock) {\n            System.out.println();\n        }\n    }\n}<\/code><\/pre>\n<h3>@Cleanup<\/h3>\n<p>\u4e3b\u8981\u7528\u6765\u4fee\u9970 IO \u6d41\u76f8\u5173\u7c7b\uff0c\u4f1a\u5728 finally \u4ee3\u7801\u5757\u4e2d\u5bf9\u8be5\u8d44\u6e90\u8fdb\u884c close();<\/p>\n<pre><code class=\"language-java\">public class CleanupExample {\n  public static void main(String[] args) throws IOException {\n    @Cleanup InputStream in = new FileInputStream(args[0]);\n    @Cleanup OutputStream out = new FileOutputStream(args[1]);\n    byte[] b = new byte[10000];\n    while (true) {\n      int r = in.read(b);\n      if (r == -1) break;\n      out.write(b, 0, r);\n    }\n  }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class CleanupExample {\n  public static void main(String[] args) throws IOException {\n    InputStream in = new FileInputStream(args[0]);\n    try {\n      OutputStream out = new FileOutputStream(args[1]);\n      try {\n        byte[] b = new byte[10000];\n        while (true) {\n          int r = in.read(b);\n          if (r == -1) break;\n          out.write(b, 0, r);\n        }\n      } finally {\n        if (out != null) {\n          out.close();\n        }\n      }\n    } finally {\n      if (in != null) {\n        in.close();\n      }\n    }\n  }\n}<\/code><\/pre>\n<h3>@Getter(lazy = true)<\/h3>\n<p>@Getter(lazy = true)\uff1a\u4e3a\u61d2\u52a0\u8f7d\u5b57\u6bb5\u751f\u6210\u4e00\u4e2aGetter\u65b9\u6cd5<\/p>\n<p>\u6807\u6ce8\u5b57\u6bb5\u4e3a\u61d2\u52a0\u8f7d\u5b57\u6bb5\uff0c\u61d2\u52a0\u8f7d\u5b57\u6bb5\u5728\u521b\u5efa\u5bf9\u8c61\u65f6\u4e0d\u4f1a\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u800c\u662f\u5728\u7b2c\u4e00\u6b21\u8bbf\u95ee\u7684\u65f6\u5019\u624d\u4f1a\u521d\u59cb\u5316\uff0c\u540e\u9762\u518d\u6b21\u8bbf\u95ee\u4e5f\u4e0d\u4f1a\u91cd\u590d\u521d\u59cb\u5316<\/p>\n<pre><code class=\"language-java\">public class User {\n\n    private final List&lt;String&gt; cityList = getCityFromCache();\n\n    private List&lt;String&gt; getCityFromCache() {\n        System.out.println(&quot;get city from cache ...&quot;);\n        return new ArrayList&lt;&gt;();\n    }\n}\n\npublic static void main(String[] args) {\n     User user = new User();  \/\/ \u521d\u59cb\u5316\u5bf9\u8c61\u65f6\u4f1a\u6267\u884cgetCityFromCache()\u65b9\u6cd5\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    @Getter(lazy = true)\n    private final List&lt;String&gt; cityList = getCityFromCache();\n\n    private List&lt;String&gt; getCityFromCache() {\n        System.out.println(&quot;get city from cache ...&quot;);\n        return new ArrayList&lt;&gt;();\n    }\n}\n\npublic class User {\n    private final AtomicReference&lt;Object&gt; cityList = new AtomicReference();\n\n    public User() {\n    }\n\n    private List&lt;String&gt; getCityFromCache() {\n        System.out.println(&quot;get city from cache ...&quot;);\n        return new ArrayList();\n    }\n\n    public List&lt;String&gt; getCityList() {\n        Object value = this.cityList.get();\n        if(value == null) {\n            AtomicReference var2 = this.cityList;\n            synchronized(this.cityList) {\n                value = this.cityList.get();\n                if(value == null) {\n                    List actualValue = this.getCityFromCache();\n                    value = actualValue == null?this.cityList:actualValue;\n                    this.cityList.set(value);\n                }\n            }\n        }\n\n        return (List)((List)(value == this.cityList?null:value));\n    }\n}\n\npublic static void main(String[] args) {\n    User user = new User();  \/\/ \u521b\u5efa\u5bf9\u8c61\u65f6\u4e0d\u4f1a\u521d\u59cb\u5316\u61d2\u52a0\u8f7d\u7684\u5b57\u6bb5\n    List&lt;String&gt; cityList = user.getCityList();  \/\/ \u53ea\u6709\u7b2c\u4e00\u6b21\u8bbf\u95ee\u5c5e\u6027\u65f6\u624d\u4f1a\u53bb\u521d\u59cb\u5316\n\n    cityList = user.getCityList();  \/\/ \u7b2c\u4e8c\u6b21\u4e0d\u4f1a\u518d\u6b21\u521d\u59cb\u5316\n}<\/code><\/pre>\n<h3>@Wither<\/h3>\n<p>\u63d0\u4f9b\u4e86\u7ed9final\u5b57\u6bb5\u8d4b\u503c\u7684\u4e00\u79cd\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">public class User {\n    @Wither\n    private final String country;\n\n    public User(String country) {\n        this.country = country;\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private final String country;\n\n    public User(String country) {\n        this.country = country;\n    }\n\n    public User withCountry(String country) {\n        return this.country == country?this:new User(country);\n    }\n}<\/code><\/pre>\n<h3>@Builder<\/h3>\n<p>@Builder\u6ce8\u91ca\u4e3a\u4f60\u7684\u7c7b\u751f\u6210\u590d\u6742\u7684\u6784\u5efa\u5668API\u3002<\/p>\n<pre><code class=\"language-java\">@Builder\npublic class User {\n    private Long id;\n    private String phone;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private Long id;\n    private String phone;\n\n    User(Long id, String phone) {\n        this.id = id;\n        this.phone = phone;\n    }\n\n    public static User.UserBuilder builder() {\n        return new User.UserBuilder();\n    }\n\n    public static class UserBuilder {\n        private Long id;\n        private String phone;\n\n        UserBuilder() {\n        }\n\n        public User.UserBuilder id(Long id) {\n            this.id = id;\n            return this;\n        }\n\n        public User.UserBuilder phone(String phone) {\n            this.phone = phone;\n            return this;\n        }\n\n        public User build() {\n            return new User(this.id, this.phone);\n        }\n\n        public String toString() {\n            return &quot;User.UserBuilder(id=&quot; + this.id + &quot;, phone=&quot; + this.phone + &quot;)&quot;;\n        }\n    }\n}<\/code><\/pre>\n<h3>@Delegate<\/h3>\n<p>\u4e3aList\u7c7b\u578b\u7684\u5b57\u6bb5\u751f\u6210\u4e00\u5927\u5806\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u5176\u5b9e\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u662fList\u4e2d\u7684\u65b9\u6cd5<\/p>\n<p>\u6ce8\u610f\uff1a\u4e00\u4e2a\u7c7b\u4e2d\u53ea\u80fd\u4f7f\u7528\u4e00\u4e2a<code>@Delegate<\/code>\u6ce8\u89e3\uff0c\u56e0\u4e3a\u4f7f\u7528\u591a\u4e2a\u4f1a\u751f\u6210\u591a\u4e2asize()\u65b9\u6cd5\uff0c\u4ece\u800c\u4f1a\u7f16\u8bd1\u62a5\u9519\u3002<\/p>\n<pre><code class=\"language-java\">public class User {\n    @Delegate\n    private List&lt;String&gt; address;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private List&lt;String&gt; address;\n\n    public User() {\n    }\n\n    public int size() {\n        return this.address.size();\n    }\n\n    public boolean isEmpty() {\n        return this.address.isEmpty();\n    }\n\n    public boolean contains(Object arg0) {\n        return this.address.contains(arg0);\n    }\n\n    public Iterator&lt;String&gt; iterator() {\n        return this.address.iterator();\n    }\n\n    public Object[] toArray() {\n        return this.address.toArray();\n    }\n\n    public &lt;T&gt; T[] toArray(T[] arg0) {\n        return this.address.toArray(arg0);\n    }\n\n    public boolean add(String arg0) {\n        return this.address.add(arg0);\n    }\n\n    public boolean remove(Object arg0) {\n        return this.address.remove(arg0);\n    }\n\n    public boolean containsAll(Collection&lt;?&gt; arg0) {\n        return this.address.containsAll(arg0);\n    }\n\n    public boolean addAll(Collection&lt;? extends String&gt; arg0) {\n        return this.address.addAll(arg0);\n    }\n\n    public boolean addAll(int arg0, Collection&lt;? extends String&gt; arg1) {\n        return this.address.addAll(arg0, arg1);\n    }\n\n    public boolean removeAll(Collection&lt;?&gt; arg0) {\n        return this.address.removeAll(arg0);\n    }\n\n    public boolean retainAll(Collection&lt;?&gt; arg0) {\n        return this.address.retainAll(arg0);\n    }\n\n    public void replaceAll(UnaryOperator&lt;String&gt; arg0) {\n        this.address.replaceAll(arg0);\n    }\n\n    public void sort(Comparator&lt;? super String&gt; arg0) {\n        this.address.sort(arg0);\n    }\n\n    public void clear() {\n        this.address.clear();\n    }\n\n    public String get(int arg0) {\n        return (String)this.address.get(arg0);\n    }\n\n    public String set(int arg0, String arg1) {\n        return (String)this.address.set(arg0, arg1);\n    }\n\n    public void add(int arg0, String arg1) {\n        this.address.add(arg0, arg1);\n    }\n\n    public String remove(int arg0) {\n        return (String)this.address.remove(arg0);\n    }\n\n    public int indexOf(Object arg0) {\n        return this.address.indexOf(arg0);\n    }\n\n    public int lastIndexOf(Object arg0) {\n        return this.address.lastIndexOf(arg0);\n    }\n\n    public ListIterator&lt;String&gt; listIterator() {\n        return this.address.listIterator();\n    }\n\n    public ListIterator&lt;String&gt; listIterator(int arg0) {\n        return this.address.listIterator(arg0);\n    }\n\n    public List&lt;String&gt; subList(int arg0, int arg1) {\n        return this.address.subList(arg0, arg1);\n    }\n\n    public Spliterator&lt;String&gt; spliterator() {\n        return this.address.spliterator();\n    }\n}<\/code><\/pre>\n<h2>lombok.config<\/h2>\n<p>lombok.config\u914d\u7f6e\u6587\u4ef6\u662f\u901a\u8fc7\u4e00\u4e9b\u8bbe\u7f6e\u6765\u63a7\u5236\u4ee3\u7801\u751f\u6210\u7684\u89c4\u5219\u6216\u8005\u79f0\u4e4b\u4e3a\u4e60\u60ef\uff0c\u914d\u7f6e\u6587\u4ef6\u7684\u4f4d\u7f6e\u5e94\u653e\u5728<code>src\/mian\/java<\/code>\uff0c\u4e0d\u8981\u653e\u7f6e\u5728<code>src\/main\/resources<\/code>\u3002<\/p>\n<p>\u6ce8\u610f\u914d\u7f6e\u6587\u4ef6\u548c\u8981\u4f7f\u7528\u6ce8\u89e3\u7684\u7c7b\u8981\u5728\u540c\u4e00\u5957\u4ee3\u7801\u4e2d\uff0c\u8981\u4e48\u540c\u65f6\u5728<code>src\/main\/java<\/code>\uff0c\u8981\u4e48\u540c\u65f6\u5728<code>src\/test\/java<\/code>\u4e2d<\/p>\n<p>lombok.config<\/p>\n<pre><code>#lombok\u9ed8\u8ba4\u5bf9boolean\u7c7b\u578b\u5b57\u6bb5\u751f\u6210\u7684get\u65b9\u6cd5\u4f7f\u7528is\u524d\u7f00\uff0c\u901a\u8fc7\u6b64\u914d\u7f6e\u5219\u4f7f\u7528get\u524d\u7f00\uff0c\u9ed8\u8ba4: false\nlombok.getter.noIsPrefix=true\n\n#\u9ed8\u8ba4\u7684set\u65b9\u6cd5\u8fd4\u56devoid\u8bbe\u7f6e\u4e3atrue\u8fd4\u56de\u8c03\u7528\u5bf9\u8c61\u672c\u8eab\uff0c\u8fd9\u6837\u65b9\u4fbf\u4f7f\u7528\u94fe\u5f0f\u6765\u7ee7\u7eed\u8c03\u7528\u65b9\u6cd5\uff0c\u9ed8\u8ba4: false\nlombok.accessors.chain=true\n\n#\u5982\u679c\u8bbe\u7f6e\u4e3atrue\uff0cget\u548cset\u65b9\u6cd5\u5c06\u4e0d\u5e26get\u548cset\u524d\u7f00\uff0c\u76f4\u63a5\u4ee5\u5b57\u6bb5\u540d\u4e3a\u65b9\u6cd5\u540d\uff0c\u9ed8\u8ba4: false\nlombok.accessors.fluent=true\n\n#\u8bbe\u7f6elog\u7c7b\u6ce8\u89e3\u8fd4\u56de\u7684\u5b57\u6bb5\u540d\u79f0\uff0c\u9ed8\u8ba4: log\nlombok.log.fieldName=logger<\/code><\/pre>\n<pre><code class=\"language-java\">@Log4j\n@Getter @Setter\npublic class User {\n    private String username;\n    private boolean vip;\n    private boolean isOldUser;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">public class User {\n    private static final Logger logger = Logger.getLogger(User.class);\n    private String username;\n    private boolean vip;\n    private boolean isOldUser;\n\n    public User() {\n    }\n\n    public String username() {\n        return this.username;\n    }\n\n    public boolean vip() {\n        return this.vip;\n    }\n\n    public boolean isOldUser() {\n        return this.isOldUser;\n    }\n\n    public User username(String username) {\n        this.username = username;\n        return this;\n    }\n\n    public User vip(boolean vip) {\n        this.vip = vip;\n        return this;\n    }\n\n    public User isOldUser(boolean isOldUser) {\n        this.isOldUser = isOldUser;\n        return this;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Lombok\u7b80\u4ecb Lombok\u662f\u4e00\u4e2a\u53ef\u4ee5\u901a\u8fc7\u6ce8\u89e3\u6765\u5e2e\u52a9\u6211\u4eec\u7b80\u5316\u6d88\u9664\u4e00\u4e9b\u5fc5\u987b\u6709\u4f46\u663e\u5f97\u5f88\u81c3\u80bf\u7684Java\u4ee3\u7801\u7684\u4e00\u79cd\u5de5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[193],"class_list":["post-2017","post","type-post","status-publish","format-standard","hentry","category-java-basic","tag-lombok"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2017"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2017\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}