Skip to content

Commit 15ed36b

Browse files
committed
Fix code style issues detected by spotless plugin
Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
1 parent 7bc18ec commit 15ed36b

File tree

5 files changed

+130
-85
lines changed

5 files changed

+130
-85
lines changed

src/main/java/com/github/markusbernhardt/xmldoclet/CustomOption.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public String getParameters() {
6666

6767
/**
6868
* Gets the list of parameters as an array of strings.
69+
*
6970
* @see #getParameters()
7071
*/
7172
public String[] getParameterArray() {

src/main/java/com/github/markusbernhardt/xmldoclet/Parser.java

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class Parser {
3333
private final static Logger LOGGER = Logger.getLogger(Parser.class.getName());
3434

3535
/**
36-
* A map where each key is a package name and each value is an object containing a package's JavaDoc.
36+
* A map where each key is a package name and each value is an object containing a package's
37+
* JavaDoc.
3738
*/
3839
protected Map<String, Package> packages = new TreeMap<>();
3940

@@ -60,13 +61,14 @@ public Set<TypeElement> getClasses(final DocletEnvironment env) {
6061
return ElementFilter.typesIn(elements);
6162
}
6263

63-
private String getJavaDoc(final Element element){
64+
private String getJavaDoc(final Element element) {
6465
final var docCommentTree = docTrees.getDocCommentTree(element);
6566
return docCommentTree == null ? "" : docCommentTree.getFullBody().toString();
6667
}
6768

6869
/**
6970
* {@return the tags inside a JavaDoc comment}
71+
*
7072
* @param element the Java element to get its JavaDoc tags
7173
*/
7274
public List<? extends DocTree> getTags(final Element element) {
@@ -86,7 +88,8 @@ public Root parseRootDoc() {
8688
final Package packageNode = getPackage(rootNode, classDoc);
8789

8890
switch (classDoc.getKind()) {
89-
case ANNOTATION_TYPE -> packageNode.getAnnotation().add(parseAnnotationTypeDoc(classDoc));
91+
case ANNOTATION_TYPE ->
92+
packageNode.getAnnotation().add(parseAnnotationTypeDoc(classDoc));
9093
case ENUM -> packageNode.getEnum().add(parseEnum(classDoc));
9194
case INTERFACE -> packageNode.getInterface().add(parseInterface(classDoc));
9295
default -> packageNode.getClazz().add(parseClass(classDoc));
@@ -98,6 +101,7 @@ public Root parseRootDoc() {
98101

99102
/**
100103
* {@return the package node for the given class element}
104+
*
101105
* @param rootNode
102106
* @param classElement class to get its package
103107
*/
@@ -144,7 +148,7 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
144148
}
145149

146150
// TODO: What does isIncluded() mean?
147-
//annotationNode.setIncluded(annotationTypeDoc.isIncluded());
151+
// annotationNode.setIncluded(annotationTypeDoc.isIncluded());
148152

149153
annotationNode.setScope(parseScope(annotationTypeDoc));
150154

@@ -154,7 +158,8 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
154158
}
155159

156160
for (final AnnotationMirror annotationDesc : annotationTypeDoc.getAnnotationMirrors()) {
157-
final var annotationInstance = parseAnnotationDesc(annotationDesc, annotationTypeDoc.getQualifiedName());
161+
final var annotationInstance =
162+
parseAnnotationDesc(annotationDesc, annotationTypeDoc.getQualifiedName());
158163
annotationNode.getAnnotation().add(annotationInstance);
159164
}
160165

@@ -171,7 +176,8 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
171176
* @param annotationTypeElementDoc A AnnotationTypeElementDoc instance
172177
* @return the annotation element node
173178
*/
174-
protected AnnotationElement parseAnnotationTypeElementDoc(final ExecutableElement annotationTypeElementDoc) {
179+
protected AnnotationElement parseAnnotationTypeElementDoc(
180+
final ExecutableElement annotationTypeElementDoc) {
175181
final AnnotationElement annotationElementNode = objectFactory.createAnnotationElement();
176182
annotationElementNode.setName(annotationTypeElementDoc.getSimpleName().toString());
177183
annotationElementNode.setQualified(annotationTypeElementDoc.getSimpleName().toString());
@@ -192,20 +198,24 @@ protected AnnotationElement parseAnnotationTypeElementDoc(final ExecutableElemen
192198
* @param programElement the name of a program element to parse
193199
* @return representation of annotations
194200
*/
195-
protected AnnotationInstance parseAnnotationDesc(final AnnotationMirror annotationDesc, final Name programElement) {
201+
protected AnnotationInstance parseAnnotationDesc(final AnnotationMirror annotationDesc,
202+
final Name programElement) {
196203
final AnnotationInstance annotationInstanceNode = objectFactory.createAnnotationInstance();
197204

198205
try {
199206
final var annotTypeInfo = annotationDesc.getAnnotationType();
200207
annotationInstanceNode.setName(annotTypeInfo.asElement().getSimpleName().toString());
201-
annotationInstanceNode.setQualified(annotTypeInfo.asElement().getSimpleName().toString());
208+
annotationInstanceNode
209+
.setQualified(annotTypeInfo.asElement().getSimpleName().toString());
202210
} catch (ClassCastException castException) {
203-
LOGGER.severe("Unable to obtain type data about an annotation found on: " + programElement);
211+
LOGGER.severe(
212+
"Unable to obtain type data about an annotation found on: " + programElement);
204213
LOGGER.severe("Add to the classpath the class/jar that defines this annotation.");
205214
}
206215

207216
for (final var elementValuesPair : annotationDesc.getElementValues().entrySet()) {
208-
final AnnotationArgument annotationArgumentNode = objectFactory.createAnnotationArgument();
217+
final AnnotationArgument annotationArgumentNode =
218+
objectFactory.createAnnotationArgument();
209219
annotationArgumentNode.setName(elementValuesPair.getKey().getSimpleName().toString());
210220

211221
final TypeMirror annotationArgumentType = elementValuesPair.getKey().asType();
@@ -218,15 +228,20 @@ protected AnnotationInstance parseAnnotationDesc(final AnnotationMirror annotati
218228
case AnnotationValue[] annotationValues -> {
219229
for (final AnnotationValue annotationValue : annotationValues) {
220230
if (annotationValue.getValue() instanceof AnnotationMirror annoDesc) {
221-
annotationArgumentNode.getAnnotation().add(parseAnnotationDesc(annoDesc, programElement));
231+
annotationArgumentNode.getAnnotation()
232+
.add(parseAnnotationDesc(annoDesc, programElement));
222233
} else {
223-
annotationArgumentNode.getValue().add(annotationValue.getValue().toString());
234+
annotationArgumentNode.getValue()
235+
.add(annotationValue.getValue().toString());
224236
}
225237
}
226238
}
227-
case VariableElement fieldDoc -> annotationArgumentNode.getValue().add(fieldDoc.getSimpleName().toString());
228-
case TypeElement classDoc -> annotationArgumentNode.getValue().add(classDoc.getQualifiedName().toString());
229-
case null -> {}
239+
case VariableElement fieldDoc ->
240+
annotationArgumentNode.getValue().add(fieldDoc.getSimpleName().toString());
241+
case TypeElement classDoc ->
242+
annotationArgumentNode.getValue().add(classDoc.getQualifiedName().toString());
243+
case null -> {
244+
}
230245
default -> annotationArgumentNode.getValue().add(objValue.toString());
231246
}
232247

@@ -246,7 +261,7 @@ protected Enum parseEnum(final TypeElement classDoc) {
246261
}
247262

248263
// TODO: What does isIncluded() mean?
249-
//enumNode.setIncluded(classDoc.isIncluded());
264+
// enumNode.setIncluded(classDoc.isIncluded());
250265

251266
enumNode.setScope(parseScope(classDoc));
252267

@@ -264,7 +279,8 @@ protected Enum parseEnum(final TypeElement classDoc) {
264279
}
265280

266281
for (final AnnotationMirror annotationDesc : classDoc.getAnnotationMirrors()) {
267-
enumNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, classDoc.getQualifiedName()));
282+
enumNode.getAnnotation()
283+
.add(parseAnnotationDesc(annotationDesc, classDoc.getQualifiedName()));
268284
}
269285

270286
for (final DocTree tag : getTags(classDoc)) {
@@ -289,7 +305,8 @@ protected EnumConstant parseEnumConstant(final VariableElement fieldDoc) {
289305
}
290306

291307
for (final AnnotationMirror annotationDesc : fieldDoc.getAnnotationMirrors()) {
292-
enumConstant.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.getSimpleName()));
308+
enumConstant.getAnnotation()
309+
.add(parseAnnotationDesc(annotationDesc, fieldDoc.getSimpleName()));
293310
}
294311

295312
for (final DocTree tag : getTags(fieldDoc)) {
@@ -309,7 +326,7 @@ protected Interface parseInterface(final TypeElement classDoc) {
309326
}
310327

311328
// TODO: What does isIncluded() mean?
312-
//interfaceNode.setIncluded(classDoc.isIncluded());
329+
// interfaceNode.setIncluded(classDoc.isIncluded());
313330

314331
interfaceNode.setScope(parseScope(classDoc));
315332

@@ -355,7 +372,7 @@ protected Class parseClass(final TypeElement classDoc) {
355372
classNode.setExternalizable(typeUtils.isExternalizable(classDoc));
356373

357374
// TODO: What does isIncluded() mean?
358-
//classNode.setIncluded(classDoc.isIncluded());
375+
// classNode.setIncluded(classDoc.isIncluded());
359376

360377
classNode.setSerializable(typeUtils.isSerializable(classDoc));
361378
classNode.setScope(parseScope(classDoc));
@@ -378,7 +395,8 @@ protected Class parseClass(final TypeElement classDoc) {
378395
}
379396

380397
for (final AnnotationMirror annotationDesc : classDoc.getAnnotationMirrors()) {
381-
final var annotationInstance = parseAnnotationDesc(annotationDesc, classDoc.getQualifiedName());
398+
final var annotationInstance =
399+
parseAnnotationDesc(annotationDesc, classDoc.getQualifiedName());
382400
classNode.getAnnotation().add(annotationInstance);
383401
}
384402

@@ -409,7 +427,7 @@ protected Constructor parseConstructor(final ExecutableElement constructorDoc) {
409427
constructorNode.setScope(parseScope(constructorDoc));
410428

411429
// TODO: What does isIncluded() mean?
412-
//constructorNode.setIncluded(constructorDoc.isIncluded());
430+
// constructorNode.setIncluded(constructorDoc.isIncluded());
413431

414432
constructorNode.setFinal(hasModifier(constructorDoc, Modifier.FINAL));
415433
constructorNode.setNative(hasModifier(constructorDoc, Modifier.NATIVE));
@@ -427,7 +445,8 @@ protected Constructor parseConstructor(final ExecutableElement constructorDoc) {
427445
}
428446

429447
for (final AnnotationMirror annotationDesc : constructorDoc.getAnnotationMirrors()) {
430-
final var annotationInstance = parseAnnotationDesc(annotationDesc, constructorDoc.getSimpleName());
448+
final var annotationInstance =
449+
parseAnnotationDesc(annotationDesc, constructorDoc.getSimpleName());
431450
constructorNode.getAnnotation().add(annotationInstance);
432451
}
433452

@@ -451,7 +470,7 @@ protected Method parseMethod(final ExecutableElement methodDoc) {
451470
methodNode.setAbstract(hasModifier(methodDoc, Modifier.ABSTRACT));
452471

453472
// TODO: What does isIncluded() mean?
454-
//methodNode.setIncluded(methodDoc.isIncluded());
473+
// methodNode.setIncluded(methodDoc.isIncluded());
455474

456475
methodNode.setFinal(hasModifier(methodDoc, Modifier.FINAL));
457476
methodNode.setNative(hasModifier(methodDoc, Modifier.NATIVE));
@@ -470,7 +489,8 @@ protected Method parseMethod(final ExecutableElement methodDoc) {
470489
}
471490

472491
for (final AnnotationMirror annotationDesc : methodDoc.getAnnotationMirrors()) {
473-
final var annotationInstance = parseAnnotationDesc(annotationDesc, methodDoc.getSimpleName());
492+
final var annotationInstance =
493+
parseAnnotationDesc(annotationDesc, methodDoc.getSimpleName());
474494
methodNode.getAnnotation().add(annotationInstance);
475495
}
476496

@@ -487,7 +507,8 @@ protected MethodParameter parseMethodParameter(final VariableElement parameter)
487507
parameterMethodNode.setType(parseTypeInfo(parameter.asType()));
488508

489509
for (final AnnotationMirror annotationDesc : parameter.getAnnotationMirrors()) {
490-
final var annotationInstance = parseAnnotationDesc(annotationDesc, parameter.getSimpleName());
510+
final var annotationInstance =
511+
parseAnnotationDesc(annotationDesc, parameter.getSimpleName());
491512
parameterMethodNode.getAnnotation().add(annotationInstance);
492513
}
493514

@@ -511,7 +532,8 @@ protected Field parseField(final VariableElement fieldDoc) {
511532
fieldNode.setConstant(requireNonNullElse(fieldDoc.getConstantValue(), "").toString());
512533

513534
for (final AnnotationMirror annotationDesc : fieldDoc.getAnnotationMirrors()) {
514-
fieldNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.getSimpleName()));
535+
fieldNode.getAnnotation()
536+
.add(parseAnnotationDesc(annotationDesc, fieldDoc.getSimpleName()));
515537
}
516538

517539
for (final DocTree tag : getTags(fieldDoc)) {
@@ -587,6 +609,7 @@ protected TagInfo parseTag(final DocTree tagDoc) {
587609

588610
/**
589611
* {@return string representation of the element scope}
612+
*
590613
* @param doc the element to get its scope
591614
*/
592615
protected String parseScope(final Element doc) {

src/main/java/com/github/markusbernhardt/xmldoclet/SupportedOptions.java

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import static java.util.stream.Collectors.toSet;
99

1010
/**
11-
* Defines the command line supported options for the XMLDoclet.
12-
* These options are used by the Apache Commons CLI library to parse the command line arguments
13-
* and define the options that the user can pass to the XMLDoclet.
14-
* This way, a List of {@link org.apache.commons.cli.Option}
15-
* is converted to a List of {@link jdk.javadoc.doclet.Doclet.Option}.
11+
* Defines the command line supported options for the XMLDoclet. These options are used by the
12+
* Apache Commons CLI library to parse the command line arguments and define the options that the
13+
* user can pass to the XMLDoclet. This way, a List of {@link org.apache.commons.cli.Option} is
14+
* converted to a List of {@link jdk.javadoc.doclet.Doclet.Option}.
15+
*
1616
* @author Manoel Campos
1717
*/
1818
final class SupportedOptions {
@@ -25,10 +25,13 @@ Options get() {
2525
newArgOption("d", "directory", "Destination directory for output file.\nDefault: .");
2626
newArgOption("docencoding", "encoding", "Encoding of the output file.\nDefault: UTF8");
2727
newNoArgOption("dryrun", "Parse javadoc, but don't write output file.\nDefault: false");
28-
newNoArgOption("rst", "Transform the XML into a Restructured Text file (*.rst).\nDefault: false");
28+
newNoArgOption("rst",
29+
"Transform the XML into a Restructured Text file (*.rst).\nDefault: false");
2930
newNoArgOption("md", "Transform the XML into a Markdown file (*.md).\nDefault: false");
30-
newNoArgOption("docbook", "Transform the XML into a DocBook file (*.db.xml).\nDefault: false");
31-
newNoArgOption("adoc", "Transform the XML into an Ascii Doctor file (*.adoc).\nDefault: false");
31+
newNoArgOption("docbook",
32+
"Transform the XML into a DocBook file (*.db.xml).\nDefault: false");
33+
newNoArgOption("adoc",
34+
"Transform the XML into an Ascii Doctor file (*.adoc).\nDefault: false");
3235
newOneArgOption("filename", "Name of the output file.\nDefault: javadoc.xml");
3336
newOneArgOption("basePackage", "Name of the base package.\n");
3437
newOneArgOption("doctitle", "Document Title\n");
@@ -40,32 +43,34 @@ Options get() {
4043
}
4144

4245
/**
43-
* Converts the Apache Commons CLI {@link org.apache.commons.cli.Option}s
44-
* to a Set of {@link jdk.javadoc.doclet.Doclet.Option} actually used by the Doclet.
45-
* @return the Set of {@link jdk.javadoc.doclet.Doclet.Option} defining the supported
46-
* options for the XMLDoclet, based on the Apache Commons CLI options.
46+
* Converts the Apache Commons CLI {@link org.apache.commons.cli.Option}s to a Set of
47+
* {@link jdk.javadoc.doclet.Doclet.Option} actually used by the Doclet.
48+
*
49+
* @return the Set of {@link jdk.javadoc.doclet.Doclet.Option} defining the supported options
50+
* for the XMLDoclet, based on the Apache Commons CLI options.
4751
*/
48-
Set<CustomOption> toDocletOptions(){
52+
Set<CustomOption> toDocletOptions() {
4953
return cliOptions.getOptions().stream().map(CustomOption::of).collect(toSet());
5054
}
5155

5256
private void newOneArgOption(final String optionName, final String description) {
5357
final var option = Option.builder(optionName)
54-
.argName(optionName)
55-
.required(false)
56-
.numberOfArgs(1)
57-
.desc(description)
58-
.build();
58+
.argName(optionName)
59+
.required(false)
60+
.numberOfArgs(1)
61+
.desc(description)
62+
.build();
5963
cliOptions.addOption(option);
6064
}
6165

62-
private void newArgOption(final String optionName, final String argName, final String description) {
66+
private void newArgOption(final String optionName, final String argName,
67+
final String description) {
6368
final var option = Option.builder(parseOptionName(optionName))
64-
.argName(parseOptionName(argName))
65-
.required(false)
66-
.hasArg()
67-
.desc(description)
68-
.build();
69+
.argName(parseOptionName(argName))
70+
.required(false)
71+
.hasArg()
72+
.desc(description)
73+
.build();
6974
cliOptions.addOption(option);
7075
}
7176

@@ -76,11 +81,11 @@ private static String parseOptionName(final String optionName) {
7681
private void newNoArgOption(final String optionName, final String description) {
7782
final var parsedOptionName = parseOptionName(optionName);
7883
final var option = Option.builder(parsedOptionName)
79-
.argName(parsedOptionName)
80-
.required(false)
81-
.hasArg(false)
82-
.desc(description)
83-
.build();
84+
.argName(parsedOptionName)
85+
.required(false)
86+
.hasArg(false)
87+
.desc(description)
88+
.build();
8489
cliOptions.addOption(option);
8590
}
8691
}

0 commit comments

Comments
 (0)