You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SuperBuilder creates its own constructor, which takes a builder instance as its only argument. This constructor copies the values from the given builder to the new instance. However, as the builder has pcs == null, the new instance also receives that null value. So this behavior is expected.
I'm afraid there is no easy solution here. If you need a reference to the instance in construction, you cannot do set in the builder, because there is no such instance, yet. So neither @Builder.Default nor @Builder.ObtainVia plus toBuilder() will work (the latter will compile, but the resulting PropertyChangeSupport instance will have a reference to the old instance, not the new one).
You could manually implement the ctor, but that would take away most of the benefits of lombok in this case: You'd have to implement the copy mechanism by yourself. What you could use is @PostConstructor#1207, but that feature is not finished, yet.
PS: @Builder.Default could provide a way out at least for @SuperBuilder, because it is only called from the ctor, so the generated init method could also be non-static. However, I remember that we had a discussion about this and we decided to leave it static, but I do not recall the reason and cannot find the discussion here on GitHub.
Describe the bug
see the following sample classes . as the result the inherited member of the base class is never initialized
To Reproduce
Expected behavior
at the point after
TestDerived x = TestDerived.builder().build();
x.pcs
should not be null.Version info (please complete the following information):
thank you for the great Tool!!!!
The text was updated successfully, but these errors were encountered: