Java lombok中@Accessors注解三個屬性的作用
Accessors翻譯是存取器。通過該注解可以控制getter和setter方法的形式。 @Accessors(fluent = true)
使用fluent屬性,getter和setter方法的方法名都是屬性名,且setter方法返回當(dāng)前對象
@Data
@Accessors(fluent = true)
class User {
private Integer id;
private String name;
// 生成的getter和setter方法如下,方法體略
public Integer id(){}
public User id(Integer id){}
public String name(){}
public User name(String name){}
}@Accessors(chain = true)
使用chain屬性,setter方法返回當(dāng)前對象
@Data
@Accessors(chain = true)
class User {
private Integer id;
private String name;
// 生成的setter方法如下,方法體略
public User setId(Integer id){}
public User setName(String name){}
}@Accessors(prefix = “f”)
使用prefix屬性,getter和setter方法會忽視屬性名的指定前綴(遵守駝峰命名)
@Data
@Accessors(prefix = "f")
class User {
private Integer fId;
private String fName;
// 生成的getter和setter方法如下,方法體略
public Integer id(){}
public void id(Integer id){}
public String name(){}
public void name(String name){}
}到此這篇關(guān)于Java lombok的@Accessors注解屬性解析的文章就介紹到這了,更多相關(guān)Java lombok@Accessors注解內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot打包發(fā)布到linux上(centos 7)的步驟
這篇文章主要介紹了SpringBoot打包發(fā)布到linux上(centos 7)的步驟,幫助大家更好的理解和使用springboot框架,感興趣的朋友可以了解下2020-12-12
Apache?Log4j2?報核彈級漏洞快速修復(fù)方法
Apache?Log4j2?是一個基于Java的日志記錄工具,是?Log4j?的升級,是目前最優(yōu)秀的?Java日志框架之一,這篇文章主要介紹了突發(fā)Apache?Log4j2?報核彈級漏洞快速修復(fù)方法,需要的朋友可以參考下2021-12-12
SpringBoot整合Hutool實現(xiàn)文件上傳的使用示例
文件上傳在項目經(jīng)常會用到,本文主要介紹了SpringBoot整合Hutool實現(xiàn)文件上傳的使用示例,具有一定的參考價值,感興趣的可以了解一下2023-11-11
關(guān)于Springboot2.x集成lettuce連接redis集群報超時異常Command timed out afte
這篇文章主要介紹了Springboot2.x集成lettuce連接redis集群報超時異常Command timed out after 6 second(s),本文通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-03-03
java報錯Cause: java.sql.SQLException問題解決
本文主要介紹了java報錯Cause: java.sql.SQLException問題解決,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08

