New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special matching for Optional types #92
Comments
I am sorry that I have not commented on this enhancement request for such a long time. |
Hey. Have you had a chance to think it thru? I'm dealing with a lot of such value objects and they usually have some mandatory and some optional fields. Supporting Optional semantics (in fields declaration) with convenience of builder will be very, very welcome addition. |
Ah, sorry, still short of time... I spent some hours thinking on this and still have no working solution. I also tried some quick hacks but they didn't work out. But I can tell some of my insights. So, let's start with the analysis: Why does the copy method NOT contain a statement like The reason is that PB does not know that
Hence there are two properties:
When PM generates the copy method it loops over all "readable" pojo properties for which a matching "with" method exists. So, what could we do now? So, how to proceed? However, I understand that this issue is important for you, and I definitely want to support you in that. Apart from that I will work again on this issue when I find time for it. I keep this issue open. |
FYI, here is a feature branch for this: https://github.com/mkarneim/pojobuilder/tree/optional-support It just implements a failing test. |
Not sure if #134 closes this? |
This is the example of annotated constructor with "partial" match on last parameter (
String
instead ofOptional<String>
)Currently PB handles such code almost right. The only issue I can see is a lack of this filed in copy() method.
This special support of Optional will be great to have because such use case seems to be very practical one for non–mandatory fields.
based on discussion in #88
The text was updated successfully, but these errors were encountered: