Skip to content

增强 JsonUtils#6145

Merged
Glavo merged 5 commits into
HMCL-dev:mainfrom
Glavo:json-utils
May 25, 2026
Merged

增强 JsonUtils#6145
Glavo merged 5 commits into
HMCL-dev:mainfrom
Glavo:json-utils

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented May 25, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors and expands JsonUtils to provide clearer nullability semantics and a broader set of convenience overloads for JSON serialization/deserialization across strings, readers, input streams, and files, while also allowing callers to supply custom Gson instances.

Changes:

  • Added @NotNullByDefault + @Nullable/@UnknownNullability type-use annotations to better document nullability behavior.
  • Introduced multiple new fromJson(...) / fromJsonFile(...) overloads (including variants accepting a caller-provided Gson), and reorganized existing helpers.
  • Expanded inline documentation for GSON/UGLY_GSON and parsing/writing helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java Outdated
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented May 25, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the JsonUtils utility class by introducing nullability annotations, comprehensive documentation, and new method overloads that support custom Gson instances. Feedback focuses on maintaining consistency in the listTypeOf return types and removing redundant explicit type arguments in generic method calls to improve readability and leverage compiler type inference.

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java Outdated
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/gson/JsonUtils.java
@Glavo Glavo changed the title 优化 JsonUtils 增强 JsonUtils May 25, 2026
@Glavo Glavo merged commit d6a4b34 into HMCL-dev:main May 25, 2026
2 checks passed
@Glavo Glavo deleted the json-utils branch May 25, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants