-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support exclusion of empty collections using experimentalExcludeEmptyCollections
#1670
Conversation
…yCollections` This matches empty optional exclusion, including discovery and remediation of a bug: Aliases may be excluded, however they were not handled correctly in the other direction, where null values were handled correctly. Now we initialize builder instances with a reference to an empty instance of alias types. This includes a new `public static T empty()` method on aliases which can handle defaults. The current implementation only checks one level of alias indirection, so alias-of-alias-of-optional/collection still won't do quite what we want, but it's a start.
Generate changelog in
|
@@ -44,4 +46,8 @@ public int hashCode() { | |||
public static SetAlias of(@Nonnull Set<String> value) { | |||
return new SetAlias(value); | |||
} | |||
|
|||
public static SetAlias empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also considered of()
rather than empty()
, matching empty object factory method, but I think this is more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no strong preference myself. empty()
sounds good!
Current state looks reasonable to me! 👍 |
Released 6.29.0 |
Linking the issue for future reference because I think its part of the reason here? palantir/conjure-typescript#78 |
This matches empty optional exclusion, including discovery
and remediation of a bug:
Aliases may be excluded, however they were not handled correctly
in the other direction, where null values were handled correctly.
Now we initialize builder instances with a reference to an empty
instance of alias types. This includes a new
public static T empty()
method on aliases which can handle defaults.
The current implementation only checks one level of alias indirection,
so alias-of-alias-of-optional/collection still won't do quite what we
want, but it's a start. Eventually we should consolidate this code.
Staged Builders
Note that this change could impact staged builders which consider
alias<optional/collection>
a required field, however such a change would be an abi break. Staged builders are not impacted by this change.Non-staged builders will no longer throw when
alias<optional/collection>
are not explicitly set, matching the behavior of an optional/collection field.After this PR
==COMMIT_MSG==
Support exclusion of empty collections using
experimentalExcludeEmptyCollections
==COMMIT_MSG==
Possible downsides?
Super duper dangerous if this is set on servers because our typescript clients do not fully implement conjure.