4747import java .util .logging .Logger ;
4848
4949/**
50+ * ProjectDocConfigBuilder
51+ *
5052 * @author yu 2019/12/21.
53+ * @since 1.8.0
5154 */
5255public class ProjectDocConfigBuilder {
5356
57+ /**
58+ * Logger
59+ */
5460 private static final Logger log = Logger .getLogger (ProjectDocConfigBuilder .class .getName ());
5561
62+ /**
63+ * JavaProjectBuilder
64+ */
5665 private final JavaProjectBuilder javaProjectBuilder ;
5766
67+ /**
68+ * classFilesMap
69+ */
5870 private final Map <String , JavaClass > classFilesMap = new ConcurrentHashMap <>();
5971
72+ /**
73+ * enumClassMap
74+ */
6075 private final Map <String , Class <? extends Enum <?>>> enumClassMap = new ConcurrentHashMap <>();
6176
77+ /**
78+ * customRespFieldMap
79+ */
6280 private final Map <CustomField .Key , CustomField > customRespFieldMap = new ConcurrentHashMap <>();
6381
82+ /**
83+ * customReqFieldMap
84+ */
6485 private final Map <CustomField .Key , CustomField > customReqFieldMap = new ConcurrentHashMap <>();
6586
87+ /**
88+ * replaceClassMap
89+ */
6690 private final Map <String , String > replaceClassMap = new ConcurrentHashMap <>();
6791
92+ /**
93+ * constantsMap
94+ */
6895 private final Map <String , String > constantsMap = new ConcurrentHashMap <>();
6996
97+ /**
98+ * serverUrl
99+ */
70100 private final String serverUrl ;
71101
102+ /**
103+ * ApiConfig
104+ */
72105 private final ApiConfig apiConfig ;
73106
107+ /**
108+ * Constructor
109+ * @param apiConfig ApiConfig
110+ * @param javaProjectBuilder JavaProjectBuilder
111+ */
74112 public ProjectDocConfigBuilder (ApiConfig apiConfig , JavaProjectBuilder javaProjectBuilder ) {
75113 if (null == apiConfig ) {
76114 throw new NullPointerException ("ApiConfig can't be null." );
@@ -105,6 +143,10 @@ public ProjectDocConfigBuilder(ApiConfig apiConfig, JavaProjectBuilder javaProje
105143 this .checkBodyAdvice (apiConfig .getResponseBodyAdvice ());
106144 }
107145
146+ /**
147+ * Init data dictionary.
148+ * @param apiConfig apiConfig
149+ */
108150 private void initDict (ApiConfig apiConfig ) {
109151 if (enumClassMap .isEmpty ()) {
110152 return ;
@@ -129,6 +171,11 @@ private void initDict(ApiConfig apiConfig) {
129171 }
130172 }
131173
174+ /**
175+ * Get enum implements by interface.
176+ * @param enumClass enumClass
177+ * @return enum implements
178+ */
132179 private Set <Class <? extends Enum <?>>> getEnumImplementsByInterface (Class <?> enumClass ) {
133180 if (!enumClass .isInterface ()) {
134181 return Collections .emptySet ();
@@ -142,6 +189,11 @@ private Set<Class<? extends Enum<?>>> getEnumImplementsByInterface(Class<?> enum
142189 return set ;
143190 }
144191
192+ /**
193+ * Get class by name.
194+ * @param simpleName simpleName
195+ * @return JavaClass
196+ */
145197 public JavaClass getClassByName (String simpleName ) {
146198 JavaClass cls = javaProjectBuilder .getClassByName (simpleName );
147199 List <DocJavaField > fieldList = JavaClassUtil .getFields (cls , 0 , new LinkedHashMap <>(), null );
@@ -158,6 +210,11 @@ public JavaClass getClassByName(String simpleName) {
158210 return cls ;
159211 }
160212
213+ /**
214+ * Load java source.
215+ * @param config ApiConfig
216+ * @param builder JavaProjectBuilder
217+ */
161218 private void loadJavaSource (ApiConfig config , JavaProjectBuilder builder ) {
162219 if (CollectionUtil .isNotEmpty (config .getJarSourcePaths ())) {
163220 for (SourceCodePath path : config .getJarSourcePaths ()) {
@@ -181,6 +238,11 @@ private void loadJavaSource(ApiConfig config, JavaProjectBuilder builder) {
181238 }
182239 }
183240
241+ /**
242+ * Load jar java source.
243+ * @param strPath path
244+ * @param builder builder
245+ */
184246 private void loadJavaSource (String strPath , JavaProjectBuilder builder ) {
185247 DirectoryScanner scanner = new DirectoryScanner (new File (strPath ));
186248 scanner .addFilter (new SuffixFilter (".java" ));
@@ -194,6 +256,11 @@ private void loadJavaSource(String strPath, JavaProjectBuilder builder) {
194256 });
195257 }
196258
259+ /**
260+ * Load jar java source.
261+ * @param path path
262+ * @param builder builder
263+ */
197264 public void loadJarJavaSource (String path , JavaProjectBuilder builder ) {
198265 OutputStream out ;
199266 if (!path .endsWith (".jar" )) {
@@ -228,6 +295,10 @@ public void loadJarJavaSource(String path, JavaProjectBuilder builder) {
228295 }
229296 }
230297
298+ /**
299+ * Delete dir.
300+ * @param file file
301+ */
231302 public static void deleteDir (File file ) {
232303 File [] files = file .listFiles ();
233304 if (file .isFile () || Objects .isNull (files ) || files .length == 0 ) {
@@ -241,6 +312,10 @@ public static void deleteDir(File file) {
241312 file .delete ();
242313 }
243314
315+ /**
316+ * Init class files map.
317+ */
318+ @ SuppressWarnings ({ "rawtypes" , "unchecked" })
244319 private void initClassFilesMap () {
245320 Collection <JavaClass > javaClasses = javaProjectBuilder .getClasses ();
246321 for (JavaClass cls : javaClasses ) {
@@ -264,6 +339,10 @@ private void initClassFilesMap() {
264339 }
265340 }
266341
342+ /**
343+ * Init custom response fields map.
344+ * @param config config
345+ */
267346 private void initCustomResponseFieldsMap (ApiConfig config ) {
268347 if (CollectionUtil .isNotEmpty (config .getCustomResponseFields ())) {
269348 for (CustomField field : config .getCustomResponseFields ()) {
@@ -273,6 +352,10 @@ private void initCustomResponseFieldsMap(ApiConfig config) {
273352 }
274353 }
275354
355+ /**
356+ * Init custom request fields map.
357+ * @param config config
358+ */
276359 private void initCustomRequestFieldsMap (ApiConfig config ) {
277360 if (CollectionUtil .isNotEmpty (config .getCustomRequestFields ())) {
278361 for (CustomField field : config .getCustomRequestFields ()) {
@@ -282,6 +365,10 @@ private void initCustomRequestFieldsMap(ApiConfig config) {
282365 }
283366 }
284367
368+ /**
369+ * Init replace class map.
370+ * @param config config
371+ */
285372 private void initReplaceClassMap (ApiConfig config ) {
286373 if (CollectionUtil .isNotEmpty (config .getApiObjectReplacements ())) {
287374 for (ApiObjectReplacement replace : config .getApiObjectReplacements ()) {
@@ -290,6 +377,10 @@ private void initReplaceClassMap(ApiConfig config) {
290377 }
291378 }
292379
380+ /**
381+ * Init constants.
382+ * @param config config
383+ */
293384 private void initConstants (ApiConfig config ) {
294385 List <ApiConstant > apiConstants ;
295386 if (CollectionUtil .isEmpty (config .getApiConstants ())) {
@@ -311,10 +402,14 @@ private void initConstants(ApiConfig config) {
311402 }
312403 }
313404 catch (ClassNotFoundException | IllegalAccessException e ) {
314- e . printStackTrace ( );
405+ log . warning ( e . getMessage () );
315406 }
316407 }
317408
409+ /**
410+ * Check body advice.
411+ * @param bodyAdvice body advice
412+ */
318413 private void checkBodyAdvice (BodyAdvice bodyAdvice ) {
319414 if (Objects .nonNull (bodyAdvice ) && StringUtil .isNotEmpty (bodyAdvice .getClassName ())) {
320415 if (Objects .nonNull (bodyAdvice .getWrapperClass ())) {
@@ -330,6 +425,9 @@ private void checkBodyAdvice(BodyAdvice bodyAdvice) {
330425 }
331426 }
332427
428+ /**
429+ * Set highlight style.
430+ */
333431 private void setHighlightStyle () {
334432 String style = apiConfig .getStyle ();
335433 if (HighLightJsConstants .HIGH_LIGHT_DEFAULT_STYLE .equals (style )) {
0 commit comments