Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Accelerate

with Lombok

by ;)heeraj

What is Lombok?

What is

Lombok

?

...or "writing" code

via @nnotation

How it works...

in your IDE

1.

How it

works...

as dependency

2.

The @nnotations

@AllArgsConstructor

generate constructor with existing fields

@Getter / @Setter

generate getters/setter for existing fields

@Getter,

@Setter

and

Co.

@EqualsAndHashCode

generate equals and hashCode

for existing fields

@ToString

generate descriptive output

for existing fields

Configure steps

Setting Up

.What you’ll need

Need..!

About 15 minutes

Eclipse IDE

JDK 1.8or later

Gradle or Maven

Download Lombok

https://projectlombok.org/download

Step 1

windows : if Java is installed double click on the lombok.jar to execute.

Linux : run the below command in terminal based on the download location.

java -Djavax.accessibility.assistive_technologies=" " -jar lombok.jar

Step 2

specify IDE path.

Step 3

if IDE is opened please close and re-open.Go to you project pox.xml and add the dependency.

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

<version>1.18.4</version>

<scope>provided</scope>

</dependency>

Update the project below is the screen short. Please make sure there are no errors in Markers.

Step 4

got to the bean or entity class and annotate with annotation provided by Lombok.

Following are the annotation most commonly used.

@Getter/@Setter -https://projectlombok.org/features/GetterSetter

Never write public int getFoo() {return foo;} again.

@ToString -https://projectlombok.org/features/ToString

No need to start a debugger to see your fields: Just let lombok generate a toString for you!

@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor-https://projectlombok.org/features/constructor

Constructors made to order: Generates constructors that take no arguments, one argument per final / non-nullfield, or one argument for every field.

@Data-https://projectlombok.org/features/Data

All together now: A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, and @Setter on all non-final fields, and @RequiredArgsConstructor!

@Builder-https://projectlombok.org/features/Builder

@Synchronized-https://projectlombok.org/features/Synchronized

@SuperBuilder -https://projectlombok.org/features/experimental/SuperBuilder

@Builder.Default-https://projectlombok.org/features/Builder

Bean class with annotations

Step 5

image

Delombok

https://projectlombok.org/features/delombok

Delombok can of course also help understand what's happening with your source by letting you look at exactly what lombok is doing 'under the hood'.

Running delombok on the command line

Delombok is included in lombok.jar. To use it, all you need to run on the command line is:

java -jar lombok.jar delombok src -d src-delomboked

Running delombok using ant ,maven

Limitations

Delombok tries to preserve your code as much as it can, but comments may move around a little bit, especially comments that are in the middle of a syntax node. For example, any comments appearing in the middle of a list of method modifiers, such as public /*comment*/ static ... will move towards the front of the list of modifiers. In practice, any java source parsing tool will not be affected.

To keep any changes to your code style to a minimum, delombok just copies a source file directly without changing any of it if the source file contains no lombok transformations.

Delombok

Why...?

What...?

Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.

Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.

Project Lombok is a mature library that reduces boilerplate code. The cases mentioned above cover just a few of those where Project Lombok can be a great benefit. The library replaces boilerplate code with easy-to-use annotations. In this article, I examine several useful features that Project Lombok provides—making code easier to read and less error-prone and making developers more productive. Best of all, the library works well with popular IDEs and provides a utility to “delombok” your code by reverting—that is, adding back all the boilerplate that was removed when the annotations were added.

What...?

How it work...!

First, a compiler takes source files and generates an AST (abstract source tree) that can be treated as Java's equivalent of DOM. The compiler calls custom registered annotation processors for the generated AST. The processors can additionally validate classes and/or generate new resources (of course new resources must be converted to AST so here we are going back to the first step). Once all processors finish their work, the compiler can finally generate byte code that will be understandable by Java Virtual Machine. it has full access to the generated source tree. While annotation processors usually generate new source files, Lombok modifies existing ones by adding new fields or methods.

How..!

Finally...!..Clean, Concise Java Code

Check for Nulls,Concise Data Objects,Builder Objects,Easy Cleanup,Effortless Logging

It takes some of the most common boilerplate headaches out of the developer’s task list. It can be useful for making your code more concise, reducing the chance for bugs, and speeding up development time

...+

Supported IDEs

IntelliJ

1.

Eclipse

2.

Netbeans

3.

Supported IDEs

Visual Studio Code

4.

and more...

5.

Documentation

https://projectlombok.org/

https://projectlombok.org/features/all

https://www.baeldung.com/intro-to-project-lombok

Read

more...

Thanks for your interest

Thank

you

Any Questions???

Learn more about creating dynamic, engaging presentations with Prezi