标签:als line tar rdate 这一 lsa sse red clean
Lombok 可用来帮助开发人员消除 Java 的重复代码,尤其是对于简单的 Java 对象(POJO),比如说getter/setter/toString等方法的编写。它通过注解实现这一目的。
官网:https://projectlombok.org
一、Eclipse中Lombok的安装
1、官网下载jar包当前版本是1.18.4,下载下来是一个lombok.jar
2、将lombok.jar移到eclipse的安装目录,即eclipse.in的同级目录
3、在eclipse.in文件最后加入下面两行
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
备注:
如果使用Lombok程序报错,可以点击eclipse菜单的Project选项的clean,清理一下即可。
二、Lombok注解说明
注解详见官网https://projectlombok.org/features/all
valFinally! Hassle-free final local variables.
varMutably! Hassle-free local variables.
@NonNullor: How I learned to stop worrying and love the NullPointerException.
@CleanupAutomatic resource management: Call your close() methods safely with no hassle.
@Getter/@SetterNever write public int getFoo() {return foo;} again.
@ToStringNo need to start a debugger to see your fields: Just let lombok generate a toString for you!
@EqualsAndHashCodeEquality made easy: Generates hashCode and equals implementations from the fields of your object..
@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructorConstructors made to order: Generates constructors that take no arguments, one argument per final / non-nullfield, or one argument for every field.
@DataAll together now: A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, and @Setter on all non-final fields, and @RequiredArgsConstructor!
@ValueImmutable classes made very easy.
@Builder... and Bob‘s your uncle: No-hassle fancy-pants APIs for object creation!
@SneakyThrowsTo boldly throw checked exceptions where no one has thrown them before!
@Synchronizedsynchronized done right: Don‘t expose your locks.
@Getter(lazy=true)Laziness is a virtue!
@LogCaptain‘s Log, stardate 24435.7: "What was that line again?"
experimentalHead to the lab: The new stuff we‘re working on.
标签:als line tar rdate 这一 lsa sse red clean
原文地址:https://www.cnblogs.com/gdjlc/p/10084014.html