Eclipse in Lombok installation instructions and notes

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

val

Finally! Hassle-free final local variables.

var

Mutably! Hassle-free 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 a toString for you!

@EqualsAndHashCode

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.

@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?"

experimental

Head to the lab: The new stuff we're working on.

Guess you like

Origin blog.csdn.net/gdjlc/article/details/84881188