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
Working on replacing a whole ton of high-arity constructor and method overloads for a moderately complex hierarchy of "do the thing" classes using a DoTheThingParameters immutable. Some of the setters need to be polymorphic, eg accepting an enum member or a string. Some are in exclusive-or groups, eg a value or a formula for computing the value at runtime. And some have legacy callsites that (sometimes) pass null to mean "use default". And icing on the cake, I need a "setter" that parses command-line style string arguments. I found the issue thread from 2015 that documents the pattern for extending the builder interface and that's doing everything I need except I can't make nullable+default work as I'd like.
Proposal: add a parameter to Value.Default(replaceNulls = true) so that the default getter is called if the underlying value is null or not set. I could probably do it with some other combination of hidden, computed and forwarded attributes but just thought I'd run this up the flagpole. I'm coding around the problem for now.
Also, I think there should be an easier-to-find write-up of this pattern. I'll submit at least an annotated example as a PR for this ticket if you like.
The text was updated successfully, but these errors were encountered:
Working on replacing a whole ton of high-arity constructor and method overloads for a moderately complex hierarchy of "do the thing" classes using a DoTheThingParameters immutable. Some of the setters need to be polymorphic, eg accepting an enum member or a string. Some are in exclusive-or groups, eg a value or a formula for computing the value at runtime. And some have legacy callsites that (sometimes) pass null to mean "use default". And icing on the cake, I need a "setter" that parses command-line style string arguments. I found the issue thread from 2015 that documents the pattern for extending the builder interface and that's doing everything I need except I can't make nullable+default work as I'd like.
Proposal: add a parameter to Value.Default(replaceNulls = true) so that the default getter is called if the underlying value is null or not set. I could probably do it with some other combination of hidden, computed and forwarded attributes but just thought I'd run this up the flagpole. I'm coding around the problem for now.
Also, I think there should be an easier-to-find write-up of this pattern. I'll submit at least an annotated example as a PR for this ticket if you like.
The text was updated successfully, but these errors were encountered: