imbajin commented on code in PR #685:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/685#discussion_r2464735293
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -226,23 +233,47 @@ public void readMode(String graph, GraphReadMode
readMode) {
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null,
readMode);
}
- public GraphReadMode readMode(String graph) {
- this.client.checkApiVersion("0.59", "graph read mode");
- RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
+ private <T extends Enum<T>> T getEnumMode(String graphSpace, String graph,
Review Comment:
⚠️ **方法命名和设计问题 (Medium)**
方法名 `getEnumMode` 作为一个通用的提取方法,存在以下问题:
1. **命名不够语义化**:建议改为 `getModeValue` 或 `getGraphModeValue`
2. **泛型约束可以更明确**:`T extends Enum<T>` 过于宽泛
3. **注释缺失**:私有方法也应该有 JavaDoc,说明参数含义和返回值
**建议添加注释:**
```java
/**
* Get graph mode value from server response
*
* @param graphSpace the graph space name, null for non-graphspace mode
* @param graph the graph name
* @param modeKey the mode key in response (MODE or GRAPH_READ_MODE)
* @param enumClass the enum class type
* @return the mode enum value
*/
private <T extends Enum<T>> T getModeValue(String graphSpace, String graph,
String modeKey, Class<T>
enumClass) {
```
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -226,23 +233,47 @@ public void readMode(String graph, GraphReadMode
readMode) {
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null,
readMode);
}
- public GraphReadMode readMode(String graph) {
- this.client.checkApiVersion("0.59", "graph read mode");
- RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
+ private <T extends Enum<T>> T getEnumMode(String graphSpace, String graph,
+ String modeKey, Class<T>
enumClass) {
Review Comment:
⚠️ **代码风格问题 (Medium)**
三元运算符过长导致可读性下降。建议改为 if-else 块:
```java
String path;
if (graphSpace != null) {
path = joinPath(this.path(), graphSpace, graph);
} else {
path = joinPath(this.path(), graph);
}
```
或者使用更清晰的三元运算符格式:
```java
String path = (graphSpace != null)
? joinPath(this.path(), graphSpace, graph)
: joinPath(this.path(), graph);
```
后者的换行格式更符合阿里巴巴Java开发规范。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]