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

Refactor Google Translate response handling to use JsonNode. #1312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miurahr
Copy link
Member

@miurahr miurahr commented Mar 23, 2025

Removed nested static classes and replaced the response parsing logic with JsonNode for improved flexibility and reduced complexity. Updated translation extraction to handle null checks more effectively and ensure robust error handling.

Pull request type

  • Other (describe below)
    refactor

Which ticket is resolved?

What does this PR change?

  • Fix the following SpotBugs errors
M V EI_EXPOSE_REP EI: org.omegat.machinetranslators.google.Google2Translate$Data.getTranslations() may expose internal representation by returning Google2Translate$Data.translations At Google2Translate.java:[line 306]	
M V EI_EXPOSE_REP2 EI2: org.omegat.machinetranslators.google.Google2Translate$Data.setTranslations(List) may expose internal representation by storing an externally mutable object into Google2Translate$Data.translations At Google2Translate.java:[line 310]	
M V EI_EXPOSE_REP EI: org.omegat.machinetranslators.google.Google2Translate$Response.getData() may expose internal representation by returning Google2Translate$Response.data At Google2Translate.java:[line 286]	
M V EI_EXPOSE_REP2 EI2: org.omegat.machinetranslators.google.Google2Translate$Response.setData(Google2Translate$Data) may expose internal representation by storing an externally mutable object into Google2Translate$Response.data At Google2Translate.java:[line 290]

Other information

Removed nested static classes and replaced the response parsing logic with JsonNode for improved flexibility and reduced complexity. Updated translation extraction to handle null checks more effectively and ensure robust error handling.

Signed-off-by: Hiroshi Miura <[email protected]>
@miurahr miurahr marked this pull request as ready for review March 29, 2025 23:47
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.

2 participants