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

Commit 652c70e

Browse files
authored
Merge pull request #802 from shalousun/master
Optimize: Optimize the repetitive code in RPC and Javadoc document ge…
2 parents eab97b3 + b03a3af commit 652c70e

7 files changed

Lines changed: 210 additions & 718 deletions

File tree

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

Lines changed: 2 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -20,261 +20,11 @@
2020
*/
2121
package com.ly.doc.model;
2222

23-
import com.ly.doc.utils.ParamUtil;
24-
import com.thoughtworks.qdox.model.JavaClass;
25-
import com.thoughtworks.qdox.model.JavaMethod;
26-
import com.thoughtworks.qdox.model.JavaType;
27-
28-
import java.util.List;
29-
import java.util.Map;
30-
3123
/**
3224
* for rpc
25+
*
3326
* @author yu 2020/1/29.
3427
*/
35-
public class RpcJavaMethod implements IMethod {
36-
37-
/**
38-
* java method
39-
*/
40-
private JavaMethod javaMethod;
41-
42-
/**
43-
* methodId handled by md5
44-
*/
45-
private String methodId;
46-
47-
/**
48-
* method name
49-
*/
50-
private String name;
51-
52-
/**
53-
* method order
54-
*/
55-
private int order;
56-
57-
58-
/**
59-
* method description
60-
*/
61-
private String desc;
62-
63-
/**
64-
* method definition
65-
*/
66-
private String methodDefinition;
67-
68-
/**
69-
* escape method definition
70-
*/
71-
private String escapeMethodDefinition;
72-
73-
/**
74-
* detailed introduction of the method
75-
*/
76-
private String detail;
77-
78-
/**
79-
* method describe
80-
*/
81-
private String throwsInfo;
82-
83-
/**
84-
* return class Info
85-
*/
86-
private String returnClassInfo;
87-
88-
/**
89-
* http request params
90-
*/
91-
private List<ApiParam> requestParams;
92-
93-
/**
94-
* http request author
95-
*/
96-
private String author;
97-
98-
/**
99-
* http response params
100-
*/
101-
private List<ApiParam> responseParams;
102-
103-
/**
104-
* method deprecated
105-
*/
106-
private boolean deprecated;
107-
108-
private Map<String, JavaType> actualTypesMap;
109-
110-
111-
private String version;
112-
113-
public String getVersion() {
114-
return version;
115-
}
116-
117-
public RpcJavaMethod setVersion(String version) {
118-
this.version = version;
119-
return this;
120-
}
121-
122-
public static RpcJavaMethod builder() {
123-
return new RpcJavaMethod();
124-
}
125-
126-
public JavaMethod getJavaMethod() {
127-
return javaMethod;
128-
}
129-
130-
public RpcJavaMethod setJavaMethod(JavaMethod javaMethod) {
131-
this.javaMethod = javaMethod;
132-
return this;
133-
}
134-
135-
public String getMethodId() {
136-
return methodId;
137-
}
138-
139-
public RpcJavaMethod setMethodId(String methodId) {
140-
this.methodId = methodId;
141-
return this;
142-
}
143-
144-
public String getName() {
145-
return name;
146-
}
147-
148-
public RpcJavaMethod setName(String name) {
149-
this.name = name;
150-
return this;
151-
}
152-
153-
public int getOrder() {
154-
return order;
155-
}
156-
157-
public RpcJavaMethod setOrder(int order) {
158-
this.order = order;
159-
return this;
160-
}
161-
162-
public String getDesc() {
163-
return desc;
164-
}
165-
166-
public RpcJavaMethod setDesc(String desc) {
167-
this.desc = desc;
168-
return this;
169-
}
170-
171-
public String getDetail() {
172-
return detail;
173-
}
174-
175-
public RpcJavaMethod setDetail(String detail) {
176-
this.detail = detail;
177-
return this;
178-
}
179-
180-
public String getThrowsInfo() {
181-
return throwsInfo;
182-
}
183-
184-
public RpcJavaMethod setThrowsInfo(String throwsInfo) {
185-
this.throwsInfo = throwsInfo;
186-
return this;
187-
}
188-
189-
public String getReturnClassInfo() {
190-
return returnClassInfo;
191-
}
192-
193-
public RpcJavaMethod setReturnClassInfo(String returnClassInfo) {
194-
this.returnClassInfo = returnClassInfo;
195-
return this;
196-
}
197-
198-
public String getAuthor() {
199-
return author;
200-
}
201-
202-
public RpcJavaMethod setAuthor(String author) {
203-
this.author = author;
204-
return this;
205-
}
206-
207-
public List<ApiParam> getResponseParams() {
208-
return responseParams;
209-
}
210-
211-
public RpcJavaMethod setResponseParams(List<ApiParam> responseParams) {
212-
this.responseParams = responseParams;
213-
return this;
214-
}
215-
216-
public boolean isDeprecated() {
217-
return deprecated;
218-
}
219-
220-
public RpcJavaMethod setDeprecated(boolean deprecated) {
221-
this.deprecated = deprecated;
222-
return this;
223-
}
224-
225-
public List<ApiParam> getRequestParams() {
226-
return requestParams;
227-
}
228-
229-
public RpcJavaMethod setRequestParams(List<ApiParam> requestParams) {
230-
this.requestParams = requestParams;
231-
return this;
232-
}
233-
234-
public String getMethodDefinition() {
235-
return methodDefinition;
236-
}
237-
238-
public RpcJavaMethod setMethodDefinition(String methodDefinition) {
239-
this.methodDefinition = methodDefinition;
240-
return this;
241-
}
242-
243-
public String getEscapeMethodDefinition() {
244-
return escapeMethodDefinition;
245-
}
246-
247-
public RpcJavaMethod setEscapeMethodDefinition(String escapeMethodDefinition) {
248-
this.escapeMethodDefinition = escapeMethodDefinition;
249-
return this;
250-
}
251-
252-
public Map<String, JavaType> getActualTypesMap() {
253-
return actualTypesMap;
254-
}
255-
256-
public RpcJavaMethod setActualTypesMap(Map<String, JavaType> actualTypesMap) {
257-
this.actualTypesMap = actualTypesMap;
258-
return this;
259-
}
260-
261-
@Override
262-
public JavaClass getDeclaringClass() {
263-
return this.javaMethod.getDeclaringClass();
264-
}
265-
266-
@Override
267-
public String getMethodName() {
268-
return this.name;
269-
}
270-
271-
@Override
272-
public List<String> getArgsClasses() {
273-
return ParamUtil.extractQualifiedName(this.requestParams);
274-
}
28+
public class RpcJavaMethod extends JavadocJavaMethod {
27529

276-
@Override
277-
public List<String> getReturnClasses() {
278-
return ParamUtil.extractQualifiedName(this.responseParams);
279-
}
28030
}

src/main/java/com/ly/doc/template/IDocBuildBaseTemplate.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.ly.doc.template;
2222

2323
import com.ly.doc.builder.ProjectDocConfigBuilder;
24+
import com.ly.doc.constants.DocTags;
2425
import com.ly.doc.constants.TornaConstants;
2526
import com.ly.doc.helper.DocBuildHelper;
2627
import com.ly.doc.model.ApiConfig;
@@ -34,6 +35,7 @@
3435
import com.power.common.util.CollectionUtil;
3536
import com.power.common.util.StringUtil;
3637
import com.thoughtworks.qdox.JavaProjectBuilder;
38+
import com.thoughtworks.qdox.model.DocletTag;
3739
import com.thoughtworks.qdox.model.JavaClass;
3840

3941
import java.util.*;
@@ -196,6 +198,26 @@ default boolean isEntryPoint(JavaProjectBuilder javaProjectBuilder, String javaC
196198
return isEntryPoint(javaClass, registeredAnnotations());
197199
}
198200

201+
default boolean skipClass( ApiConfig apiConfig ,JavaClass javaClass, FrameworkAnnotations frameworkAnnotations) {
202+
if (StringUtil.isNotEmpty(apiConfig.getPackageFilters())) {
203+
// from smart config
204+
if (!DocUtil.isMatch(apiConfig.getPackageFilters(), javaClass)) {
205+
return true;
206+
}
207+
}
208+
if (StringUtil.isNotEmpty(apiConfig.getPackageExcludeFilters())) {
209+
if (DocUtil.isMatch(apiConfig.getPackageExcludeFilters(), javaClass)) {
210+
return true;
211+
}
212+
}
213+
// from tag
214+
DocletTag ignoreTag = javaClass.getTagByName(DocTags.IGNORE);
215+
if (!isEntryPoint(javaClass, frameworkAnnotations) || Objects.nonNull(ignoreTag)) {
216+
return true;
217+
}
218+
return false;
219+
}
220+
199221
/**
200222
* is entry point
201223
*

0 commit comments

Comments
 (0)