0

I am new to lombok. I need to create using fields given below except Id. How can i define it?

for example:

@Data
Public Class Test{

private Integer id;

private String name;

private String address;

private address age;

}

I just need to create constructor using fields name,address and age. This might be silly question but any sample code would be appreciated

Sharon Ben Asher
  • 13,849
  • 5
  • 33
  • 47
Praveen Kumar
  • 27
  • 1
  • 4
  • Does this answer your question? [Omitting one Setter/Getter in Lombok](https://stackoverflow.com/questions/7994119/omitting-one-setter-getter-in-lombok) – happy songs Oct 20 '22 at 07:24
  • 1
    Counterpoint: why do you need to do it with lombok? I find that the autogenerated methods just make debugging more complicated because no IDE supports "find usages" on lombok methods. Could you just write the constructor in vanilla code? Maybe use IDE's "create constructor" functionality. – Torben Oct 20 '22 at 07:25
  • I was trying to learn how to use lombok. I can write own custom constructor in java but i want to use @RequiredArgConstructor to provide custom implementation. – Praveen Kumar Oct 20 '22 at 07:52
  • Does this answer your question? [Java Lombok: Omitting one field in @AllArgsConstructor?](https://stackoverflow.com/questions/23761242/java-lombok-omitting-one-field-in-allargsconstructor) – Chaosfire Oct 20 '22 at 08:21
  • @PraveenKumar The second answer, which is about using `lombok.NonNull` is what you are looking for. – Chaosfire Oct 20 '22 at 08:25
  • @Torben Intellij can find usages of lombok generated methods through the field. The downside is that both getters and setters are found like this, but it works. – Chaosfire Oct 20 '22 at 08:28
  • 1
    @Chaosfire My usual use cases are "who instantiates this class" and "who sets this field". While better than how Eclipse works (or doesn't work), it's still not ideal. – Torben Oct 20 '22 at 09:33
  • Eclipse does also find usages of Lombok methods using the outline. – Jan Rieke Oct 20 '22 at 10:41

0 Answers0