Skip to content
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

Merged
merged 5 commits into from
Feb 23, 2022

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Feb 22, 2022

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.

…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.
@changelog-app
Copy link

changelog-app bot commented Feb 22, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Support exclusion of empty collections using experimentalExcludeEmptyCollections

Check the box to generate changelog(s)

  • Generate changelog entry

@carterkozak carterkozak requested a review from fawind February 22, 2022 19:45
@@ -44,4 +46,8 @@ public int hashCode() {
public static SetAlias of(@Nonnull Set<String> value) {
return new SetAlias(value);
}

public static SetAlias empty() {
Copy link
Contributor Author

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.

Copy link
Contributor

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!

@fawind
Copy link
Contributor

fawind commented Feb 23, 2022

Current state looks reasonable to me! 👍

@carterkozak carterkozak marked this pull request as ready for review February 23, 2022 13:28
@bulldozer-bot bulldozer-bot bot merged commit df2c2c6 into develop Feb 23, 2022
@bulldozer-bot bulldozer-bot bot deleted the ckozak/exclude_empty_collections branch February 23, 2022 13:28
@svc-autorelease
Copy link
Collaborator

Released 6.29.0

@fawind
Copy link
Contributor

fawind commented Apr 10, 2024

Possible downsides?
Super duper dangerous if this is set on servers because our typescript clients do not fully implement conjure.

Linking the issue for future reference because I think its part of the reason here? palantir/conjure-typescript#78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants