Lombok

Lombok

Lombok is a very useful library helping avoid lots of boiler plate code. Its simple and easy to use. This tool helps you get rid of generating getter / setters and constructors thus saving a few clicks while writing your classes.
Your classes now would look neat and crisp with fewer lines.


Documentation Link : 

https://projectlombok.org/features/all


Steps :

  1. Download the lombok jar (https://projectlombok.org/download). 
  2. Double click on it and install the same. 



Dependency in pom file  - Add the below dependency in the pom file.


<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.12</version>
</dependency>

Adding the lambok jar in eclipse :

  1. Build path -> configure build path 
  2. Add external jar -> find the downloaded jar and add it here.
Once this is done with annotations getter setters can be used in code. Eclipse would not show any error.

Sample code with annotations 


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CakeShop {
private String address;
private String city;
private int name;
}



Comments