Skip to content
Advertisement

Why any initialization or even print inside the constructor with @Tolerate lombok cannot be reached?

what is the problem with the constructor with @Tolerate of lombok, and why it cannot be reached? and how can I fix it? I wanna initialize a map by setting some default keys and values inside the constructor block, but it cannot be initialize because nothing can be reached inside the constructor. Would you please help me? thank you.

JavaScript

OUTPUT:

test 1: {}

Advertisement

Answer

@Builder does not use a no-args constructor, it uses an all-args constructor. If you want your builder to use your own constructor, manually implement an all-args constructor, but do not annotate it with @Tolerate (otherwise Lombok would try to generate another, which will lead to a compilation error).

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement