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

chore(client): json util supply method to parse json list #577

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

Conversation

diaohancai
Copy link

Purpose of the PR

Main Changes

org.apache.hugegraph.util.JsonUtil supply method to parse json list.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • org.apache.hugegraph.unit.JsonUtilTest

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. client hugegraph-client enhancement New feature or request java Pull requests that update Java code labels Feb 7, 2024
@diaohancai diaohancai changed the title chore: json util supply method to parse json list chore(client): json util supply method to parse json list Feb 7, 2024
Comment on lines +66 to +76
public static <T> List<T> fromJson2List(String json, Class<T> clazz) {
try {
return MAPPER.readValue(json, getCollectionType(List.class, clazz));
} catch (IOException e) {
throw new SerializeException("Failed to deserialize json '%s'", e, json);
}
}

private static JavaType getCollectionType(Class<?> collectionClass,
Class<?>... elementClasses) {
return MAPPER.getTypeFactory().constructParametricType(collectionClass, elementClasses);
Copy link
Member

@imbajin imbajin Feb 7, 2024

Choose a reason for hiding this comment

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

shall we consider moving the JsonUtil to hugegraph-common module?

@imbajin
Copy link
Member

imbajin commented Feb 20, 2024

image

license header (add we'll provide a doc to setup IDEA soon)

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (b066b80) 62.49% compared to head (6cff118) 62.54%.
Report is 19 commits behind head on master.

Files Patch % Lines
.../main/java/org/apache/hugegraph/util/JsonUtil.java 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #577      +/-   ##
============================================
+ Coverage     62.49%   62.54%   +0.04%     
- Complexity     1903     1925      +22     
============================================
  Files           262      267       +5     
  Lines          9541     9681     +140     
  Branches        886      888       +2     
============================================
+ Hits           5963     6055      +92     
- Misses         3190     3237      +47     
- Partials        388      389       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -60,4 +62,17 @@ public static <T> T convertValue(JsonNode node, Class<T> clazz) {
e, node);
}
}

public static <T> List<T> fromJson2List(String json, Class<T> clazz) {
Copy link
Contributor

Choose a reason for hiding this comment

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

move to line 56?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client hugegraph-client enhancement New feature or request java Pull requests that update Java code size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Chore] json util supply method to parse json list
3 participants