Questions tagged [lombok]

Project Lombok is a tool for reducing boilerplate code in Java through annotations and compile time code generation.

The details for project Lombok can be found at http://projectlombok.org/.

The primary functionality of Lombok is reducing the boilerplate code in JavaBeans by replacing all setters, getters, equals, hashCode and toString with a single @Data annotation on the class.

Many other useful features are offered and the project is under active development.

1764 questions
454
votes
15 answers

Is it safe to use Project Lombok?

In case you don't know Project Lombok helps with some of the annoyances of Java with stuff like generating getters and setters with annotations and even simple JavaBean like generation with @Data. It could really help me, especially in 50 different…
TheLQ
  • 14,081
  • 11
  • 66
  • 104
273
votes
4 answers

Omitting one Setter/Getter in Lombok

I want to use a data class in Lombok. Since it has about a dozen fields, I annotated it with @Data in order to generate all the setters and getter. However there is one special field for which I don't want to the accessors to be implemented. How…
DerMike
  • 13,362
  • 12
  • 45
  • 60
237
votes
35 answers

Can't compile project when I'm using Lombok under IntelliJ IDEA

I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11. I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields. So I have a class that uses Slf4j. I annotated…
expert
  • 26,897
  • 27
  • 105
  • 198
232
votes
11 answers

Lombok annotations do not compile under Intellij idea

I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13). Added lombok.jar into classpath I can find getters and setters in the window of structure. And Intellij shows no error. Setting - Lombok plugin - Verified Intellij configuration…
yurnom
  • 2,321
  • 2
  • 10
  • 4
174
votes
18 answers

Lombok added but getters and setters not recognized in Intellij IDEA

I am using IntelliJ IDEA on ubuntu. I added lombok.jar into my project and installed the Lombok plugin for IDEA. I have access to the annotations but the getters and setters aren't generated. I get the same errors I would get if I tried accessing a…
Don Quixote
  • 3,818
  • 3
  • 14
  • 25
159
votes
4 answers

How does lombok work?

I met lombok today. I'm very anxious to know how it works. A Java Geek Article gives some clues but it's not perfectly clear to me: Java 6 removes apt and make javac able to manage annotations, streamlining the process to obtain a simpler …
uuidcode
  • 3,167
  • 3
  • 22
  • 28
137
votes
7 answers

how to Call super constructor in Lombok

I have a class @Value @NonFinal public class A { int x; int y; } I have another class B @Value public class B extends A { int z; } lombok is throwing error saying it cant find A() constructor, explicitly call it what i want lombok to…
user2067797
  • 1,502
  • 2
  • 9
  • 10
137
votes
30 answers

Building with Lombok's @Slf4j and Intellij: Cannot find symbol log

I have a maven project that builds with no problems from the command line. However, when I build it with IntelliJ, I get the error: java: FileName.java:89: cannot find symbol symbol : variable log There is no log defined or imported in the java…
user1991839
  • 1,643
  • 2
  • 12
  • 11
129
votes
3 answers

Build an object from an existing one using lombok

Lets say I have a lombok annotated class like @Builder class Band { String name; String type; } I know I can do: Band rollingStones = Band.builder().name("Rolling Stones").type("Rock Band").build(); Is there an easy way to create an object…
Mustafa
  • 4,080
  • 3
  • 20
  • 36
121
votes
23 answers

Lombok is not generating getter and setter

I just tried to send a Maven-based project to another computer and HORROR, red markers everywhere!! However, mvn clean install is building just fine. Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the…
Heetola
  • 4,431
  • 7
  • 26
  • 44
119
votes
4 answers

Warning equals/hashCode on @Data annotation lombok with inheritance

I have a entity which inherits from other. On other hand, I'm using lombok project to reduce boilerplate code, so I put @Data annotation. The annotation @Data with inheritance produces the next warning: Generating equals/hashCode implementation but…
Pau
  • 11,098
  • 10
  • 54
  • 83
106
votes
17 answers

Can't make Jackson and Lombok work together

I am experimenting in combining Jackson and Lombok. Those are my classes: package testelombok; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import…
Victor Stafusa
  • 12,608
  • 11
  • 54
  • 67
102
votes
4 answers

Java Lombok: Omitting one field in @AllArgsConstructor?

If I specify @AllArgsConstructor using Lombok, it will generate a constructor for setting all the declared (not final, not static) fields. Is it possible to omit some field and this leave generated constructor for all other fields?
user3656823
  • 1,023
  • 2
  • 7
  • 4
99
votes
9 answers

MapStruct and Lombok not working together

Tech Stack being used : Java 8 MapStruct : 1.2.0.Final Lombok: 1.16.18 IDE: IntelliJ - Lombok Plugin already installed Initially, I faced issues when I removed getters and setters and added @Getter and @Setter annotation, mapstruct is not able to…
Vivek Gupta
  • 1,565
  • 2
  • 12
  • 22
84
votes
8 answers

Lombok @Builder and JPA Default constructor

I'm using project Lombok together with Spring Data JPA. Is there any way to connect Lombok @Builder with JPA default constructor? Code: @Entity @Builder class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long…
krzakov
  • 2,991
  • 8
  • 31
  • 48
1
2 3
99 100