I have this simple class
public class ErrorDetails {
private String param = null;
private String moreInfo = null;
private String reason = null;
...
}
After refactoring, I added @Data and @Builder, but all the instantiations doesn't work any more
ErrorDetails errorDetails = new ErrorDetails();
'ErrorDetails(java.lang.String, java.lang.String, java.lang.String)' is not public in 'com.nordea.openbanking.payments.common.ndf.client.model.error.ErrorDetails'. Cannot be accessed from outside package
If I removed @Builder, then it will work fine,
Why I cannot use @Data and @Builder together?
Lombok's @Builder must have @AllArgsConstructor in order to work
Adding also @AllArgsConstructor should do
Under the hood it build all fields using constructor with all fields
applying
@Builderto a class is as if you added@AllArgsConstructor(access = AccessLevel.PACKAGE)to the class and applied the@Builderannotation to this all-args-constructor. This only works if you haven't written any explicit constructors yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With