1
1
package com .github .markusbernhardt .xmldoclet ;
2
2
3
- import com .github .markusbernhardt .xmldoclet .xjc .Annotation ;
4
- import com .github .markusbernhardt .xmldoclet .xjc .AnnotationArgument ;
5
- import com .github .markusbernhardt .xmldoclet .xjc .AnnotationElement ;
6
- import com .github .markusbernhardt .xmldoclet .xjc .AnnotationInstance ;
7
3
import com .github .markusbernhardt .xmldoclet .xjc .Class ;
8
- import com .github .markusbernhardt .xmldoclet .xjc .Constructor ;
9
4
import com .github .markusbernhardt .xmldoclet .xjc .Enum ;
10
- import com .github .markusbernhardt .xmldoclet .xjc .EnumConstant ;
11
- import com .github .markusbernhardt .xmldoclet .xjc .Field ;
12
- import com .github .markusbernhardt .xmldoclet .xjc .Interface ;
13
- import com .github .markusbernhardt .xmldoclet .xjc .Method ;
14
- import com .github .markusbernhardt .xmldoclet .xjc .MethodParameter ;
15
- import com .github .markusbernhardt .xmldoclet .xjc .ObjectFactory ;
16
5
import com .github .markusbernhardt .xmldoclet .xjc .Package ;
17
- import com .github .markusbernhardt .xmldoclet .xjc .Root ;
18
- import com .github .markusbernhardt .xmldoclet .xjc .TagInfo ;
19
- import com .github .markusbernhardt .xmldoclet .xjc .TypeInfo ;
20
- import com .github .markusbernhardt .xmldoclet .xjc .TypeParameter ;
21
- import com .github .markusbernhardt .xmldoclet .xjc .Wildcard ;
6
+ import com .github .markusbernhardt .xmldoclet .xjc .*;
22
7
import com .sun .source .doctree .DocTree ;
23
8
import com .sun .source .util .DocTrees ;
24
9
import jdk .javadoc .doclet .DocletEnvironment ;
41
26
* @author markus
42
27
*/
43
28
public class Parser {
44
-
45
29
private final static Logger LOGGER = Logger .getLogger (Parser .class .getName ());
46
30
47
- protected Map <String , Package > packages = new TreeMap <String , Package >();
31
+ protected Map <String , Package > packages = new TreeMap <>();
48
32
49
33
protected ObjectFactory objectFactory = new ObjectFactory ();
50
34
private DocTrees docTrees ;
@@ -59,7 +43,6 @@ private String getJavaDoc(final Element element){
59
43
return docCommentTree == null ? "" : docCommentTree .getFullBody ().toString ();
60
44
}
61
45
62
-
63
46
/**
64
47
* {@return the package element of the class}
65
48
* @param classElement class to get its package
@@ -138,7 +121,7 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
138
121
annotationNode .setName (annotationTypeDoc .name ());
139
122
annotationNode .setQualified (annotationTypeDoc .qualifiedName ());
140
123
String comment = annotationTypeDoc .commentText ();
141
- if (comment .length () > 0 ) {
124
+ if (! comment .isEmpty () ) {
142
125
annotationNode .setComment (comment );
143
126
}
144
127
annotationNode .setIncluded (annotationTypeDoc .isIncluded ());
@@ -188,8 +171,7 @@ protected AnnotationElement parseAnnotationTypeElementDoc(final ExecutableElemen
188
171
* @param programElement programElement
189
172
* @return representation of annotations
190
173
*/
191
- protected AnnotationInstance parseAnnotationDesc (final AnnotationMirror annotationDesc ,
192
- String programElement ) {
174
+ protected AnnotationInstance parseAnnotationDesc (final AnnotationMirror annotationDesc , String programElement ) {
193
175
AnnotationInstance annotationInstanceNode = objectFactory .createAnnotationInstance ();
194
176
195
177
try {
@@ -232,7 +214,7 @@ protected AnnotationInstance parseAnnotationDesc(final AnnotationMirror annotati
232
214
}
233
215
234
216
protected Enum parseEnum (final TypeElement classDoc ) {
235
- Enum enumNode = objectFactory .createEnum ();
217
+ final Enum enumNode = objectFactory .createEnum ();
236
218
enumNode .setName (classDoc .name ());
237
219
enumNode .setQualified (classDoc .qualifiedName ());
238
220
String comment = classDoc .commentText ();
@@ -242,7 +224,7 @@ protected Enum parseEnum(final TypeElement classDoc) {
242
224
enumNode .setIncluded (classDoc .isIncluded ());
243
225
enumNode .setScope (parseScope (classDoc ));
244
226
245
- TypeMirror superClassType = classDoc .superclassType ();
227
+ final TypeMirror superClassType = classDoc .superclassType ();
246
228
if (superClassType != null ) {
247
229
enumNode .setClazz (parseTypeInfo (superClassType ));
248
230
}
@@ -273,7 +255,7 @@ protected Enum parseEnum(final TypeElement classDoc) {
273
255
* @return
274
256
*/
275
257
protected EnumConstant parseEnumConstant (final VariableElement fieldDoc ) {
276
- EnumConstant enumConstant = objectFactory .createEnumConstant ();
258
+ final EnumConstant enumConstant = objectFactory .createEnumConstant ();
277
259
enumConstant .setName (fieldDoc .name ());
278
260
String comment = fieldDoc .commentText ();
279
261
if (comment .length () > 0 ) {
@@ -292,7 +274,7 @@ protected EnumConstant parseEnumConstant(final VariableElement fieldDoc) {
292
274
}
293
275
294
276
protected Interface parseInterface (final TypeElement classDoc ) {
295
- Interface interfaceNode = objectFactory .createInterface ();
277
+ final Interface interfaceNode = objectFactory .createInterface ();
296
278
interfaceNode .setName (classDoc .name ());
297
279
interfaceNode .setQualified (classDoc .qualifiedName ());
298
280
String comment = classDoc .commentText ();
@@ -331,7 +313,7 @@ protected Interface parseInterface(final TypeElement classDoc) {
331
313
}
332
314
333
315
protected Class parseClass (final TypeElement classDoc ) {
334
- Class classNode = objectFactory .createClass ();
316
+ final Class classNode = objectFactory .createClass ();
335
317
classNode .setName (classDoc .name ());
336
318
classNode .setQualified (classDoc .qualifiedName ());
337
319
String comment = classDoc .commentText ();
@@ -384,7 +366,7 @@ protected Class parseClass(final TypeElement classDoc) {
384
366
}
385
367
386
368
protected Constructor parseConstructor (final ExecutableElement constructorDoc ) {
387
- Constructor constructorNode = objectFactory .createConstructor ();
369
+ final Constructor constructorNode = objectFactory .createConstructor ();
388
370
389
371
constructorNode .setName (constructorDoc .name ());
390
372
constructorNode .setQualified (constructorDoc .qualifiedName ());
@@ -422,7 +404,7 @@ protected Constructor parseConstructor(final ExecutableElement constructorDoc) {
422
404
}
423
405
424
406
protected Method parseMethod (final ExecutableElement methodDoc ) {
425
- Method methodNode = objectFactory .createMethod ();
407
+ final Method methodNode = objectFactory .createMethod ();
426
408
427
409
methodNode .setName (methodDoc .name ());
428
410
methodNode .setQualified (methodDoc .qualifiedName ());
@@ -474,7 +456,7 @@ protected MethodParameter parseMethodParameter(final VariableElement parameter)
474
456
}
475
457
476
458
protected Field parseField (final VariableElement fieldDoc ) {
477
- Field fieldNode = objectFactory .createField ();
459
+ final Field fieldNode = objectFactory .createField ();
478
460
fieldNode .setType (parseTypeInfo (fieldDoc .type ()));
479
461
fieldNode .setName (fieldDoc .name ());
480
462
fieldNode .setQualified (fieldDoc .qualifiedName ());
@@ -501,7 +483,7 @@ protected Field parseField(final VariableElement fieldDoc) {
501
483
}
502
484
503
485
protected TypeInfo parseTypeInfo (final TypeMirror type ) {
504
- TypeInfo typeInfoNode = objectFactory .createTypeInfo ();
486
+ final TypeInfo typeInfoNode = objectFactory .createTypeInfo ();
505
487
typeInfoNode .setQualified (type .qualifiedTypeName ());
506
488
String dimension = type .dimension ();
507
489
if (dimension .length () > 0 ) {
@@ -524,7 +506,7 @@ protected TypeInfo parseTypeInfo(final TypeMirror type) {
524
506
}
525
507
526
508
protected Wildcard parseWildcard (final WildcardType wildcard ) {
527
- Wildcard wildcardNode = objectFactory .createWildcard ();
509
+ final Wildcard wildcardNode = objectFactory .createWildcard ();
528
510
529
511
for (final TypeMirror extendType : wildcard .extendsBounds ()) {
530
512
wildcardNode .getExtendsBound ().add (parseTypeInfo (extendType ));
@@ -544,7 +526,7 @@ protected Wildcard parseWildcard(final WildcardType wildcard) {
544
526
* @return
545
527
*/
546
528
protected TypeParameter parseTypeParameter (final TypeVariable typeVariable ) {
547
- TypeParameter typeParameter = objectFactory .createTypeParameter ();
529
+ final TypeParameter typeParameter = objectFactory .createTypeParameter ();
548
530
typeParameter .setName (typeVariable .typeName ());
549
531
550
532
for (final TypeMirror bound : typeVariable .bounds ()) {
0 commit comments