Project Lombok is a Java library tool that generates code for minimizing boilerplate code. The library replaces boilerplate code with easy-to-use annotations.
For example, by adding a couple of annotations, you can get rid of code clutters, such as getters and setters methods, constructors, hashcode, equals, and toString methods, and so on.
We have written a lot of boilerplate code such as getter, setter, equals, hashCode methods etc. in Java for years. In some cases, this causes problems in subjects like clean and readable code.
For such situations, Project Lombok saves our eyes . Also, you will be able to spend more time on the business logic using Lombok.
“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 uses annotations to avoid boilerplate code. In the best cases, only five lines can replace hundreds of lines of code.
@Data | |
@AllArgsConstructor | |
@NoArgsConstructor | |
@Entity | |
@Table | |
public class Book { | |
@Id | |
@GeneratedValue | |
private Long id; | |
private String writer; | |
private String name; | |
private String genre; | |
private String year; | |
}
Descriptions of used annotations according to JavaDoc:
|
Comments
Post a Comment