How to run code after constructor in a Lombok builder

后端 未结 4 1653
庸人自扰
庸人自扰 2021-02-07 01:38

I have a class that I want to use Lombok.Builder and I need pre-process of some parameters. Something like this:

@Builder
public class Foo {
   public String val         


        
4条回答
  •  故里飘歌
    2021-02-07 02:23

    In Foo you could manually add a constructor, have that do the initialization, and put @Builder on the constructor. I know that you already know this, but I think it is the right solution, and you won't forget to add the parameter since you do want to use the code in the builder anyway.

    Disclosure: I am a lombok developer.

提交回复
热议问题