Skip to content

Comments

[Java] Consolidates all operation parameters transformation and inspection#6737

Merged
anuchandy merged 6 commits intomicrosoft:mainfrom
anuchandy:param-transformation-improv
Apr 1, 2025
Merged

[Java] Consolidates all operation parameters transformation and inspection#6737
anuchandy merged 6 commits intomicrosoft:mainfrom
anuchandy:param-transformation-improv

Conversation

@anuchandy
Copy link
Member

@anuchandy anuchandy commented Mar 27, 2025

This pull-request,

  1. consolidates all operation parameters transformation and inspection of those transformations from various parts of the code.
  2. adds extensive Java documentation focusing generator devs.
  3. couple of conditional checks have been simplified when possible.

With this pull request, we have slightly reduced the amount of code in ClientMethodMapper and a few other places. No behavior changes are introduced.

Autorest verification pr: Azure/autorest.java#3055

@anuchandy anuchandy self-assigned this Mar 27, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Mar 27, 2025
@github-actions
Copy link
Contributor

No changes needing a change description found.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Mar 27, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@anuchandy anuchandy force-pushed the param-transformation-improv branch from d619ccb to 621f3ec Compare March 27, 2025 22:35
@anuchandy anuchandy force-pushed the param-transformation-improv branch from 621f3ec to 9c9eb6d Compare March 28, 2025 23:33
… useful methods to ParameterTransformation, and introduce ParameterTransformations to hold collection of ParameterTransformation with functions inspect this inner collection.
@anuchandy anuchandy force-pushed the param-transformation-improv branch from c4fa34d to 055bfc0 Compare April 1, 2025 01:59
@anuchandy anuchandy added this pull request to the merge queue Apr 1, 2025
Merged via the queue into microsoft:main with commit c405595 Apr 1, 2025
25 checks passed
@anuchandy anuchandy deleted the param-transformation-improv branch April 1, 2025 03:22
mario-guerra pushed a commit that referenced this pull request Apr 2, 2025
…ction (#6737)

This pull-request,

1. consolidates all operation parameters transformation and inspection
of those transformations from various parts of the code.
2. adds extensive Java documentation focusing generator devs.
3. couple of conditional checks have been simplified when possible.

With this pull request, we have slightly reduced the amount of code in
`ClientMethodMapper` and a few other places. No behavior changes are
introduced.

Autorest verification pr:
Azure/autorest.java#3055
github-merge-queue bot pushed a commit that referenced this pull request Apr 4, 2025
This PR addresses a regression introduced in the
[PR](#6737).

In 6737, a `List<MethodTransformationDetails>` representing mappings
were replaced with a new type `ParameterTransformations` that composes
an `immutable` list of mapping.

The original list was the JDK `ArrayList<>` that internally implements
`equals()` and `hashcode()` (e.g., those equality impl ensures different
list with zero elements as equal).

The new type `ParameterTransformations` introduced inherits the
`equals()` and `hashcode()` from `Object`, so two distinct references
are always different. Additionally, the composed `immutable` list is JDK
`ImmutableList`, unlike `ArrayList`, it doesn’t not implement `equals()`
and `hashcode()` but inherits Object's.

The `ClientMethod` composes `ParameterTransformations ` (earlier `List<
MethodTransformationDetails >`) property.

The generator needs to find distinct list of `ClientMethods`, and the
proper comparison requires all composed properties type to support
equality checks. So, with changes 6737, there were duplicate
`ClientMethod`, resulting in emitted Java class to have same function
appears twice.

Fixes: Azure/autorest.java#3061

Autorest [PR](Azure/autorest.java#3063)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants