Lombok A library for getting rid of getter setter for your Pojo.

Recently i got a chance to work on microservices ,In existing code i observed some annotations in my pojo or JPA entities and did not see any setter or getter for properties defined. But in my whole code getter and setter were getting used .I realized there is something going behind the scene and these annotation are generating setter getter for my JPA during compilation time. After some research i had an answer. answer was a library known as lombok :)

Getters/Setters, Constructors — So Repetitive

Encapsulating object properties via public getter and setter methods is such a common practice in the Java world, and lots of frameworks rely on this “Java Bean” pattern extensively: a class with an empty constructor and get/set methods for “properties”.

@Entity 
public class User implements Serializable {
private @Id Long id; // will be set when persisting
private String firstName;
private String lastName;
private int age;
public User() { }
public User(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
//getters and setters: ~30 extra lines of code
}
@Entity 
@Getter
@Setter
@NoArgsConstructor // <--- THIS is it public class User implements Serializable {
private @Id Long id; // will be set when persisting
private String firstName;
private String lastName;
private int age;
public User(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
}
<dependencies>     
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
</dependencies>

Angular,Vuejs,Android,Java,Git developer. i am nerd who want to learn new technologies, goes in depth.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store