Lombok: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:
==@Data==
==@Data==


Generates getters and setters for member variables.
{{External|https://projectlombok.org/features/Data}}
 
Generates:
* Getters for all fields
* A useful toString() method
* hashCode() and equals() implementations that check all non-transient fields
* Setters for all non-final fields
* A constructor
 
Equivalent to [[#@Getter|@Getter]] [[#@Setter|@Setter]], [[#@RequiredArgsConstructor|@RequiredArgsConstructor]] [[#@ToString|@ToString]] [[#@EqualsAndHashCode|@EqualsAndHashCode]]
 
==@Getter==
 
==@Setter==
 
==@RequiredArgsConstructor==
 
==@ToString==
 
==@EqualsAndHashCode==

Revision as of 18:37, 10 October 2018

Overview

Lombok is a Java annotation library that helps reduce boilerplate code.

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

https://projectlombok.org/features/Data

Generates:

  • Getters for all fields
  • A useful toString() method
  • hashCode() and equals() implementations that check all non-transient fields
  • Setters for all non-final fields
  • A constructor

Equivalent to @Getter @Setter, @RequiredArgsConstructor @ToString @EqualsAndHashCode

@Getter

@Setter

@RequiredArgsConstructor

@ToString

@EqualsAndHashCode