-
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
[Enhancement] Strict Staged Builders Support Primitive Optimized Collections #2464
base: bmarcaurele/new-native-collection-apis
Are you sure you want to change the base?
[Enhancement] Strict Staged Builders Support Primitive Optimized Collections #2464
Conversation
conjure-java-core/src/integrationInput/java/com/palantir/product/PrimitiveStrictExample.java
Outdated
Show resolved
Hide resolved
Type type = enriched.conjureDef().getType(); | ||
Optional<LogSafety> safety = safetyEvaluator.getUsageTimeSafety(enriched.conjureDef()); | ||
|
||
ImmutableList.Builder<MethodSpec> builder = ImmutableList.builder(); | ||
|
||
if (type.accept(TypeVisitor.IS_LIST)) { | ||
if (isPrimitiveOptimized(type)) { |
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.
Hoisted this up as having it nested in the auxiliary setters was a hold over from a time before isPrimitiveOptimized
properly guarded for collection types only. Hence it needing to be nested inside a type.accept(TypeVisitor.IS_LIST)
. However, this is not strictly a refactor for refactor's sake. I did need to add the primitive setter in more cases than what this method is used for.
07e5ae9
to
6341c75
Compare
Yup, chatted with Pritham about this. I'm not in a rush so would rather not disrupt Kunal. |
6341c75
to
2bcf64a
Compare
@kunalrkak @mpritham It rebased eerily cleanly. I still ran edit: I think I should still address #2464 (comment) before this merges. Its a good suggestion. It will only be a one line change in the generation code. So a review on this need not wait, but you can if you want. |
2bcf64a
to
4e1d5c7
Compare
183925a
to
1f6bc08
Compare
Before this PR
When using
useStrictStagedBuilders
andnonNullCollections
the generated builders did not allow for the optimal (non-boxing) path (#2389), nor did it optimally handle Jackson deserialization (#2431).After this PR
Strict staged builders now expose additional, optimized setters and also leverage these setters for Jackson deserialization.
==COMMIT_MSG==
==COMMIT_MSG==
Possible downsides?
IMO this class is becoming unwieldy. It has two similar, but somewhat divergent code paths between strict and non-strict builders. You cannot simply hoist the strictness to the top level because it has entry points like
addStagedBuilder
which you can call even whenuseStrictStagedBuilders
is set to true? Kinda feels like we should have different builder implementations for each of the paths through and we then factor out the bit of shared behavior. IDK it felt bad adding all theseboolean strict
all over the place.In addition, I added some complexity to support adding the collection reset. If we are comfortable allowing people to cast into the base builder and break shit.. Then I can remove some of these unwanted
boolean stricts
.