Lombok: Difference between revisions
Jump to navigation
Jump to search
(→@Slf4j) |
|||
Line 6: | Line 6: | ||
Lombok is a Java annotation library that helps reduce boilerplate code. | Lombok is a Java annotation library that helps reduce boilerplate code. | ||
=Gradle Dependency= | |||
<syntaxhighlight lang='groovy'> | |||
dependencies { | |||
implementation('org.projectlombok:lombok') | |||
} | |||
</syntaxhighlight> | |||
=Annotations= | =Annotations= |
Revision as of 23:15, 11 October 2018
External
Overview
Lombok is a Java annotation library that helps reduce boilerplate code.
Gradle Dependency
dependencies {
implementation('org.projectlombok:lombok')
}
Annotations
@Slf4j
The annotation generates a SLF4J Logger in the class. It has the same effect as if you were to explicitly add the following lines within the class:
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MyClass.class);
@Data
Generates:
- Getters for all fields
- Setters for all non-final fields
- A constructor with corresponding arguments for all fields
- A useful toString() method
- hashCode() and equals() implementations that check all non-transient fields
Equivalent to @Getter @Setter, @RequiredArgsConstructor @ToString @EqualsAndHashCode