Lombok @Data Annotation

Lombok is used to reduce boilerplate code for model/data objects, e.g., it can generate getters and setters for those object automatically by using Lombok annotations. The easiest way is to use the @Data annotation.

By annotating the class with @Data , you get the same effect as setting all the following annotations.

  • @ToString
  • @Getter
  • @Setter
  • @RequiredArgsConstructor
  • @EqualsAndHashCode

 

import lombok.Data;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;@Entity@Datapublic class Todo {    @Id    @GeneratedValue(strategy = GenerationType.IDENTITY)    private Long id;    private String summary;    private String description;}

By simply adding the @data annotation you get all this for free:

Lombok Data Annotation
Lombok Data Annotation

See this Article For @Data Annotation with examples: Java Lombok Tutorial