Home Project Lombok
Post
Cancel

Project Lombok

Visit their site: Lombok

Learn this next abbreviation, it will be used more and more often:

1
DTO [Data Transfer Object]

What is Lombok?

logo

How to use Lombok: read the Guide

Read me -> REDUCING BOILERPLATE CODE WITH PROJECT LOMBOK

Lombok does boilerplate for us. It has IDE support for:

  • Setters
  • Getters
  • Equals
  • Hashcode
  • ToString

Pro-tip: search around on Google to learn what Getters and Setters are

Pro-tip: search around on Google to learn a DTO is in Java

An @ annotation will generate all boilerplate for us with Lombok

1
2
3
4
5
6
7
8
@Builder
@Setter
@Getter
@Data
@EqualsandHashcode
@NoArgsConstructor
@AllAArgsConstructor
@NonNull

Pro-tip: If these things are completely new to you, better step up your game.

This is all about Objects,and programming is all about Objects too.

Public is the default access level for getters and setters unless you change it.

We will learn about Public and Private access levels soon.

Add Lombok to project/ pom.xml (Maven)

This is an important step if you work with Lombok, fortunately you already know what maven is, and when we get to Spring and their starter, you will discover that you can easily pick up Lombok for any project. This will make you a great developer.

Add Maven Dependency for Lombok in the pom.xml

1
2
3
4
5
6
7
8
        <!-- compile dependencies -->
        <dependencies>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <scope>provided</scope>
            </dependency>
        </dependencies>

This is the example code that you can copy-pasta into your pom.xml to start using Lombok.


Project Lombok Training

This will teach you a lot about Lombok. But perhaps it’s just enough to watch these clips for now. Today is all about awareness of Lombok, and the superpower it can bestow on you when you know how to handle this infinity stone.


Start daily exercises in the Code Gym

Start with: Start your journey to become a Java Developer

Continue with: Mapstruct

This post is licensed under CC BY 4.0 by the author.