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.

2384 questions
0
votes
1 answer

Abstract objects setting attributes in base class

Hello I have the following class structure - @Getter @SuperBuilder(toBuilder = true) @ToString @NoArgsConstructor abstract class A { String a; } @Getter @SuperBuilder(toBuilder = true) @ToString @AllArgsConstructor class B extends A { String…
0
votes
1 answer

@PostConstruct on parametrised bean

I have parametrised interface and parametrised class that implements this interface. Than I inject this class into 3 services and set typeParameterClass in @PostConstruct method. 2 classes return correct typeParameterClass, but other one returns…
Alex A
  • 33
  • 5
0
votes
1 answer

Spring boot: Cannot resolve method 'builder' in 'Product'

I have used @builder anotation of lombok in Product class. But when I use Product.builder(), it's not work. Also, the getter and setter are cannot resolve. I have tried to downgrade some lombok versions, still not working. This is my code in…
0
votes
1 answer

Lombok Constructor annotation with a single custom field initialization

I would like to update this sample code by using a lombok annotation. But I struggle to extract the registerCount initialization from the constructor, because it depends on the injected collectorRegistry…
TomDoes
  • 274
  • 1
  • 16
0
votes
0 answers

ModelMapper not working mapping Entity to DTO

I am trying to convert an Entity to a DTO using ModelMapper and when mapping the properties are always to null, when the Entity is returning the values correctly: Entity: package org.example.model; import jakarta.persistence.*; import…
0
votes
2 answers

How you deal with logging stacktrace using lombok in spring boot?

For security reason I decided to avoid printStackTrace to the console. Instead, I'm doing log.error("Error occored: {}", e); Now, this solution work as the stacktrace is shown only in the log file and not in the consule. While this approcah is good…
user2304483
  • 1,462
  • 6
  • 28
  • 50
0
votes
1 answer

Lombok gives java: unreported exception java.lang.Exception; must be caught or declared to be thrown

If I am not wrong, Lombok's @Data gives the getter, setter and other util methods. Developer can customize its generated methods. And I did that before. But recently I have come across a scenario where I can't customize the mothods. Here my…
0
votes
1 answer

Lombok @Builder @Singular in Map obtain value

I annotated with @Singular to a Map, but I can't obtain the Map variable in the builder object. My Class: @Getter @Builder public class WebServiceStatus { private final String wsdl; private final String operation; …
fvpaz
  • 1
  • 2
  • 2
0
votes
0 answers

Log4j2's logging patterns are not displaying properly

I am running an application that logs things using Log4j2. I am configuring the logging programmically using the code below: ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder(); …
Factor Three
  • 2,094
  • 5
  • 35
  • 51
0
votes
0 answers

Lombok @Getter not setting private access level when using onMethod_ attribute

I am using Java 11 and Lombok 1.18.26. When I try to set the access level of my getter method to private using the @Getter annotation with the onMethod_ attribute, like this: @Getter(value = PRIVATE, onMethod_={@JsonGetter(value = "rating")}), the…
Denis Kisina
  • 350
  • 4
  • 19
0
votes
0 answers

vscode is showing compilation error on using lombok

I am working on a spring boot project and added the maven dependency for lombok and also installed the ** Lombok Annotations Support for VS Code ** .I am using the latest version of lombok and dependecy looks like this :
0
votes
0 answers

Swagger ignoring @Schema annotation for write only fields

The POST API takes a payload with couple of fields where one of them is a write only field. The class has lombok @Data annotation to generate setters/getters and the write only field is annotated with @Getter(AccessLevel.NONE). Since lombok is used,…
vinodpthmn
  • 1,062
  • 14
  • 28
0
votes
2 answers

Use of Lombok @SneakyThrows annotation

I am trying to use Lombok library in my spring boot application. I came across @SneakyThrows annotation. But I didn't really get the full use of it. Usually if there could be an exception, it's always good to catch/throw it and also the caller can…
Lolly
  • 34,250
  • 42
  • 115
  • 150
0
votes
1 answer

Spring Boot JSON decoding error: Unrecognized field even when DTO has the fields

I am new to Spring Boot and Java so excuse my ignorance. I tried Googling but they all point me to Jackson errors which is what this is but I guess I am using Jackson implicitly by using @RequestBody annotation in my controller (correct me if I am…
streetsoldier
  • 1,259
  • 1
  • 14
  • 32
0
votes
0 answers

Java + Lombok + Log - passing the logger to the parent class

How can I pass the logger to the parent class using Lombok? This is how I would do it creating loggers by myself: public abstract class Parent { private final Logger log = LoggerFactory.getLogger(getClass()); public void execute() { …
1 2 3
99
100