'RequiredArgsConstructor with custom assignment
I'm curious if it's possible to assign a custom value during a constructor call using @RequiredArgsConstructor. I.e.
private String value1;
private String value2;
private String value3;
public MyConstructor(String value1, String value2) {
this.value1 = value1;
this.value2 = value2;
this.value3 = createString();
}
Instead I'll be looking for:
@RequiredArgsConstructor
public class MyConstructor {
@NonNull
private String value1;
@NonNull
private String value2;
private String value3;
private String createString() {
return "test";
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
