Lombok is a simple form of annotations that can help us simplify the elimination of some of the necessary but very bloated Java code tools, by using the corresponding annotations, you can compile the source code when the corresponding method is generated
Pom dependency:
<dependency> <groupId>org.projectlombok</groupId> <artifactid>lombok</ Artifactid></dependency>
Here are just a few of the frequently used annotations, see https://projectlombok.org/features/index.html
@Getter/@Setter
Can be used on classes and attributes, placed on a class, generates a Getter/setter method on all non-static (Non-static) properties, and on the property, generates Getter/setter methods on the property. You can also specify the access level of the Getter/setter method.
@EqualsAndHashCode
By default, all non-transient (non-transient) and non-static (non-static) fields are used to generate the Equals and Hascode methods, or you can specify which properties are used specifically.
@ToString
Generates the ToString method, which, by default, outputs the class name, all properties, and the attributes are output in sequential order, separated by commas.
@NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor
The parameterless constructor, the partial parameter constructor, and the full parameter constructor, Lombok is powerless when we need to overload multiple constructors.
@Data
@ToString, @EqualsAndHashCode, the @getter of all attributes, the combination of @setter and @requiredargsconstructor of all non-final properties, usually we use this annotation as sufficient
Use the example (the following 5 annotations, you can use only @data annotations instead):
@Getter @setter@tostring@noargsconstructor@equalsandhashcode Public class userentity { private String ID; Private String lastName; Private String email; Private Integer age;}
Java's Lombok