Using Lombok, is it possible to specify a one arg constructor?
My intention is to use Lombok annotations to create a constructor such as the one below.
class MyClass {
private String param;
private Integer count;
public MyClass(String param) {
this.param = param;
}
}
Lombok doesn't let you to specify the fields exactly, but there are 3 annotations to choose from. With
@RequiredArgsConstructor class MyClass {
private final String param;
private Integer count;
}
you can get it. An argument is required if it's not initialized inline and final
or @NonNull
.