Java Lombok: Omitting one field in @AllArgsConstructor?

后端 未结 3 2092
不知归路
不知归路 2020-12-09 00:36

If I specify @AllArgsConstructor using Lombok, it will generate a constructor for setting all the declared (not final, not static) fields. Is it p

相关标签:
3条回答
  • 2020-12-09 00:55

    A good way to go around it in some cases would be to use the @Builder

    0 讨论(0)
  • 2020-12-09 01:11

    Alternatively, you could use @RequiredArgsConstructor. This adds a constructor for all fields that are either @NonNull or final.

    See the documentation

    0 讨论(0)
  • 2020-12-09 01:19

    No that is not possible. There is a feature request to create a @SomeArgsConstructor where you can specify a list of involved fields.

    Full disclosure: I am one of the core Project Lombok developers.

    0 讨论(0)
提交回复
热议问题