Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude property from Lombok builder?

I have a class called as "XYZClientWrapper" , which have following structure:

@Builder XYZClientWrapper{     String name;     String domain;     XYZClient client; } 

What I want no build function generated for property XYZClient client

Does Lombok supports such use case?

like image 529
Vivek Goel Avatar asked Jun 08 '15 19:06

Vivek Goel


People also ask

How do I ignore NULL values in Lombok?

You can ignore null fields at the class level by using @JsonInclude(Include. NON_NULL) to only include non-null fields, thus excluding any attribute whose value is null.

What is @builder annotation in Lombok?

Lombok's @Builder annotation is a useful technique to implement the builder pattern that aims to reduce the boilerplate code. In this tutorial, we will learn to apply @Builder to a class and other useful features. Ensure you have included Lombok in the project and installed Lombok support in the IDE.

What is the use of @builder annotation?

The @Builder annotation produces complex builder APIs for your classes. @Builder lets you automatically produce the code required to have your class be instantiable with code such as: Person. builder()

Is Lombok builder thread safe?

It is thread safe. In the method builder a new AddressBuilder object is created, so it is always working with a new object. The methods are only using local variables, no shared variables.


1 Answers

Yes, you can place @Builder on a constructor or static (factory) method, containing just the fields you want.

Disclosure: I am a Lombok developer.

like image 110
Roel Spilker Avatar answered Oct 01 '22 03:10

Roel Spilker