lombok的@Accessors注解3个属性说明
https://www.cnblogs.com/kelelipeng/p/11326936.html
https://www.cnblogs.com/kelelipeng/p/11326621.html
2019.05.21 11:29:03字数 114阅读 1,455
Accessors翻译是存取器。通过该注解可以控制getter和setter方法的形式。
@Accessors(fluent = true)
使用fluent属性,getter和setter方法的方法名都是属性名,且setter方法返回当前对象
@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方法返回当前对象
@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){}
}
lombok的@Accessors注解3个属性说明的更多相关文章
- lombok的@Accessors注解
@AllArgsConstructor @Data @NoArgsConstructor @Accessors(chain = true) @EqualsAndHashCode public clas ...
- Spring Boot 2 实践记录之 使用 ConfigurationProperties 注解将配置属性匹配至配置类的属性
在 Spring Boot 2 实践记录之 条件装配 一文中,曾经使用 Condition 类的 ConditionContext 参数获取了配置文件中的配置属性.但那是因为 Spring 提供了将上 ...
- Lombok之@Builder注解
Lombok之@Builder注解 前言 Lombok大家都知道,在使用POJO过程中,它给我们带来了很多便利,省下大量写get.set方法.构造器.equal.toString方法的时间.除此之外, ...
- SpringMVC的数据格式化-注解驱动的属性格式化
一.什么是注解驱动的属性格式化? --在bean的属性中设置,SpringMVC处理 方法参数绑定数据.模型数据输出时自动通过注解应用格式化的功能. 二.注解类型 1.DateTimeFormat @ ...
- Springboot 在@Configuration注解的勒种 使用@Autowired或者@value注解 读取.yml属性失败
springboot中@value注解,读取yml属性失败 问题场景: 配置ShrioConfig时,想注入.yml的参数进行配置 解决办法: 如果注释掉shiroEhcacheManager 以下所 ...
- eclipse安装lombok和常用注解使用
1.下载lombok.jar lombok 的官方网址:http://projectlombok.org/ 2.运行lombok.jar: java -jar D:\eclipse-luna\l ...
- 就因为加了Lombok的@Accessors(chain = true),bean拷贝工具类不干活了
前言 这次新建了一个工程,因为 Lombok 用得很习惯,但以前的话,一般只用了@Data,@AllArgsConstructor,@EqualsAndHashCode等常规注解:那这个Accesso ...
- Eclipse安装lombok及常用注解
转自:https://blog.csdn.net/ZJDWHD/article/details/77795023 lombok的官方网址:http://projectlombok.org/ https ...
- lombok的常用注解
出处: https://blog.csdn.net/sunnyzyq/article/details/119992746 1. @Accessors 源码 我们打开 @Accessors 的源码可以看 ...
随机推荐
- Android 中指纹识别
Android从6.0系统开始就支持指纹认证功能了,指纹功能还需要有硬件支持才行 指纹与手机系统设置的指纹进行匹配 如图: 在LoginActivity 中弹出指纹验证Fragment,验证成功进入M ...
- 【已采纳】supervisor在服务器端(linux),如何一直运行你的python代码
正式开始之前,说一下我的项目是放在虚拟环境里的,具体什么是虚拟环境,怎么创建,请自行百度噢! 一.安装 源码安装 先下载最新的supervisor安装包:https://pypi.python.o ...
- 001-Zabbix 服务安装
Zabbix 服务安装 [官方地址]点我快速打开文章 1.安装 Zabbix 1.1 下载 Zabbix 清华源 rpm -ivh https://mirrors.tuna.tsinghua.edu. ...
- Codeforces Round #304 (Div. 2)(CF546E) Soldier and Traveling(最大流)
题意 给定 n 个城市,m 条边.人只能从走相邻边相连(只能走一次)的城市. 现在给你初始城市的每一个人数,再给一组每个城市人数.询问是否可以从当前人数变换到给定人数.如果能,输入"YES& ...
- 非root用户安装、配置mysql
1. 下载mysql,可能是因为服务器操作系统版本较低(CentOS4.3),安装5.7时提示缺lib,刚好我不需要一定安装新版,所以下载了5.1 Linux - Generic (glibc 2.5 ...
- sikuli 搜索例子
#coding:utf-8kw = input(u"请输入您要搜索的关键字:")#openAPP('C:\Users\ceshi\AppData\Local\Google\Chr ...
- 18-numpy笔记-莫烦pandas-6-plot显示
代码 import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.Series(np.random ...
- 5 Ways AI is Transforming the Finance Industry
https://marutitech.com/ways-ai-transforming-finance/ As global technology has evolved over the years ...
- webapi序列化控制
我们都知道在使用WebApi的时候Controller会自动将Action的返回值自动进行各种序列化处理(序列化为json,xml等),但是如果Controller的自动序列化后的结果不是我们想要的该 ...
- [LeetCode] 623. Add One Row to Tree 二叉树中增加一行
Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value ...