Lombok can be used to help Java developers to eliminate duplicate code, especially for simple Java objects (POJO), for example, the preparation method of getter / setter / toString and so on. It does this by annotation.
Official website: https: //projectlombok.org
A, Eclipse is mounted in Lombok
1, the official website to download the current version is 1.18.4 jar package, download a lombok.jar
2, the installation directory lombok.jar move eclipse, i.e., the same directory eclipse.in
3, in the final document eclipse.in Add the following two lines
-Xbootclasspath / A: lombok.jar
-javaagent: lombok.jar
Note:
If you use a program error Lombok, clean eclipse can click on the Project menu option, you can clean up.
Two, Lombok explanatory notes
Notes See the official website https://projectlombok.org/features/all
Finally! Hassle-free final local variables.
Mutably! Hassle-free local variables.
or: How I learned to stop worrying and love the NullPointerException.
Automatic resource management: Call your close()
methods safely with no hassle.
Never write public int getFoo() {return foo;}
again.
No need to start a debugger to see your fields: Just let lombok generate a toString
for you!
Equality made easy: Generates hashCode
and equals
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-nullfield, or one argument for every field.
All together now: A shortcut for @ToString
, @EqualsAndHashCode
, @Getter
on all fields, and @Setter
on all non-final fields, and @RequiredArgsConstructor
!
Immutable classes made very easy.
... and Bob's your uncle: No-hassle fancy-pants APIs for object creation!
To boldly throw checked exceptions where no one has thrown them before!
synchronized
done right: Don't expose your locks.
Laziness is a virtue!
Captain's Log, stardate 24435.7: "What was that line again?"
Head to the lab: The new stuff we're working on.