Call the correct method of oneof examples #3180
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Context
PR #3177 fixed constructor collisions in oneOf types by using static factory methods when multiple types have the same type erasure (e.g.,
List<String>andList<Double>both erase toList). However, the example generation code was not updated to use these new factory methods, causing compilation failures in generated examples.Issue
The failing example in PR #3057 attempted to instantiate
CustomAttributeValuesUnionwith aList<String>:This fails because
CustomAttributeValuesUnionhas:oneOf: String, List<String>, Double, List<Double>List<String>andList<Double>(collision detected)Changes
Updated
.generator/src/generator/formatter.pyto detect type erasure collisions when generating examples:_format_oneof(): Now callsprepare_oneof_methods()to determine whether to use a regular constructor or static factory methodformat_data_with_schema_list(): Same collision detection for list-based oneOf typesThe example generator now correctly produces:
Test
This fix resolves the compilation failure in PR #3057's
UpdateCaseCustomAttribute.javaexample.