关闭

lombok最全的,最新的学习资料,demo【最全的注解】打开蓝色注解链接

标签: lombok
334人阅读 评论(0) 收藏 举报
分类:

面试的时候,有问起这个lombok是什么玩意儿? 当时没有使用过,感觉挺好奇的,简单研究了下

打开下方蓝色注解链接-有惊喜

lombok官方地址: https://projectlombok.org/download.html


使用Maven来添加支持

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.10</version>
</dependency>

使用idea插件,需要安装,设置下。















下面贴一些官网的demo:

val
Finally! Hassle-free final local variables.
@NonNull
or: How I learned to stop worrying and love the NullPointerException.
@Cleanup
Automatic resource management: Call your close() methods safely with no hassle.
@Getter /@Setter
Never write public int getFoo() {return foo;} again.
@ToString
No need to start a debugger to see your fields: Just let lombok generate atoString for you!
@EqualsAndHashCode
Equality made easy: Generates hashCode andequals implementations from the fields of your object.
@NoArgsConstructor,@RequiredArgsConstructor and@AllArgsConstructor
Constructors made to order: Generates constructors that take no arguments, one argument per final / non-null field, or one argument for every field.
@Data
All together now: A shortcut for @ToString,@EqualsAndHashCode,@Getter on all fields, and@Setter on all non-final fields, and@RequiredArgsConstructor!
@Value
Immutable classes made very easy.
@Builder
... and Bob's your uncle: No-hassle fancy-pants APIs for object creation!
@SneakyThrows
To boldly throw checked exceptions where no one has thrown them before!
@Synchronized
synchronized done right: Don't expose your locks.
@Getter(lazy=true)
Laziness is a virtue!
@Log
Captain's Log, stardate 24435.7: "What was that line again?"
Configuration system
Lombok, made to order: Configure lombok features in one place for your entire project or even your workspace.
Experimental features
Here be dragons: Extra features which aren't quite ready for prime time yet.



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:454951次
    • 积分:5268
    • 等级:
    • 排名:第5415名
    • 原创:152篇
    • 转载:49篇
    • 译文:1篇
    • 评论:63条
    最新评论