Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit 6360b3d

Browse files
authored
Merge pull request #941 from linwumingshi/fix/list-empty
fix: 🐛 Resolve error caused by `EmptyList` being final
2 parents 368ccc2 + d0ce2fb commit 6360b3d

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/main/java/com/ly/doc/model/AbstractRpcApiDoc.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.ly.doc.model;
22

3-
import com.power.common.util.CollectionUtil;
4-
53
import java.io.Serializable;
64
import java.util.ArrayList;
7-
import java.util.Collections;
85
import java.util.List;
96
import java.util.Objects;
107

118
/**
129
* Abstract API Doc.
1310
*
11+
* @author linwumingshi
1412
* @param <T> the type of method doc
1513
*/
1614
public abstract class AbstractRpcApiDoc<T extends IMethod>
@@ -180,8 +178,8 @@ public String getDocClass() {
180178

181179
@Override
182180
public List<IMethod> getMethods() {
183-
if (CollectionUtil.isEmpty(this.list)) {
184-
return Collections.emptyList();
181+
if (Objects.isNull(this.list)) {
182+
return new ArrayList<>();
185183
}
186184
return new ArrayList<>(this.list);
187185
}

src/main/java/com/ly/doc/model/ApiDoc.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121
package com.ly.doc.model;
2222

23-
import com.power.common.util.CollectionUtil;
2423
import com.power.common.util.StringUtil;
2524

2625
import java.util.ArrayList;
@@ -153,8 +152,8 @@ public void setName(String name) {
153152
}
154153

155154
public List<ApiMethodDoc> getList() {
156-
if (CollectionUtil.isEmpty(this.list)) {
157-
return Collections.emptyList();
155+
if (Objects.isNull(this.list)) {
156+
return new ArrayList<>();
158157
}
159158
return list;
160159
}
@@ -263,8 +262,8 @@ public String getDocClass() {
263262

264263
@Override
265264
public List<IMethod> getMethods() {
266-
if (CollectionUtil.isEmpty(this.list)) {
267-
return Collections.emptyList();
265+
if (Objects.isNull(this.list)) {
266+
return new ArrayList<>();
268267
}
269268

270269
return new ArrayList<>(this.list);

src/main/java/com/ly/doc/model/WebSocketDoc.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
*/
2121
package com.ly.doc.model;
2222

23-
import java.util.Collections;
23+
import java.util.ArrayList;
2424
import java.util.List;
25+
import java.util.Objects;
2526

2627
/**
2728
* the webSocket doc
@@ -76,8 +77,8 @@ public void setSubProtocols(String subProtocols) {
7677
}
7778

7879
public List<ApiParam> getPathParams() {
79-
if (pathParams == null) {
80-
return Collections.emptyList();
80+
if (Objects.isNull(this.pathParams)) {
81+
return new ArrayList<>();
8182
}
8283
return pathParams;
8384
}
@@ -88,7 +89,7 @@ public void setPathParams(List<ApiParam> pathParams) {
8889

8990
public List<ApiParam> getMessageParams() {
9091
if (messageParams == null) {
91-
return Collections.emptyList();
92+
return new ArrayList<>();
9293
}
9394
return messageParams;
9495
}

src/main/java/com/ly/doc/model/javadoc/JavadocApiDoc.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
import com.ly.doc.model.IDoc;
2424
import com.ly.doc.model.IMethod;
2525
import com.ly.doc.model.JavadocJavaMethod;
26-
import com.power.common.util.CollectionUtil;
2726

2827
import java.util.ArrayList;
29-
import java.util.Collections;
3028
import java.util.List;
3129
import java.util.Objects;
3230

31+
/**
32+
* Java Doc ApiDoc
33+
*
34+
* @author chenchuxin
35+
* @since 3.0.5
36+
*/
3337
public class JavadocApiDoc implements IDoc, Comparable<JavadocApiDoc> {
3438

3539
/**
@@ -181,8 +185,8 @@ public String getDocClass() {
181185

182186
@Override
183187
public List<IMethod> getMethods() {
184-
if (CollectionUtil.isEmpty(this.list)) {
185-
return Collections.emptyList();
188+
if (Objects.isNull(this.list)) {
189+
return new ArrayList<>();
186190
}
187191
return new ArrayList<>(this.list);
188192
}

0 commit comments

Comments
 (0)