@@ -27,20 +27,19 @@ final class SupportedOptions {
27
27
28
28
public SupportedOptions () {
29
29
this .supportedOptionsSet = Set .of (
30
- newArgOption ("d" , "directory" , "Destination directory for output file.\n Default: ." ),
31
- newArgOption ("docencoding" , "encoding" , "Encoding of the output file.\n Default: UTF8" ),
32
- newNoArgOption ("dryrun" , "Parse javadoc, but don't write output file.\n Default: false" ),
33
- newNoArgOption ("rst" , "Transform the XML into a Restructured Text file (*.rst).\n Default: false" ),
34
- newNoArgOption ("md" , "Transform the XML into a Markdown file (*.md).\n Default: false" ),
35
- newNoArgOption ("docbook" , "Transform the XML into a DocBook file (*.db.xml).\n Default: false" ),
36
- newNoArgOption ("adoc" , "Transform the XML into an Ascii Doctor file (*.adoc).\n Default: false" ),
37
- newOneArgOption ("filename" , "Name of the output file.\n Default: javadoc.xml" ),
38
- newOneArgOption ("basePackage" , "Name of the base package.\n " ),
39
- newOneArgOption ("doctitle" , "Document Title\n " ),
40
- newOneArgOption ("windowtitle" , "Window Title\n " ),
41
- newNoArgOption ("noTimestamp" , "No Timestamp.\n " ),
42
- newNoArgOption ("withFloatingToc" , "Renders a Floating TOC on the right side.\n " )
43
- );
30
+ newArgOption ("d" , "directory" , "Destination directory for output file.\n Default: ." ),
31
+ newArgOption ("docencoding" , "encoding" , "Encoding of the output file.\n Default: UTF8" ),
32
+ newNoArgOption ("dryrun" , "Parse javadoc, but don't write output file.\n Default: false" ),
33
+ newNoArgOption ("rst" , "Transform the XML into a Restructured Text file (*.rst).\n Default: false" ),
34
+ newNoArgOption ("md" , "Transform the XML into a Markdown file (*.md).\n Default: false" ),
35
+ newNoArgOption ("docbook" , "Transform the XML into a DocBook file (*.db.xml).\n Default: false" ),
36
+ newNoArgOption ("adoc" , "Transform the XML into an Ascii Doctor file (*.adoc).\n Default: false" ),
37
+ newOneArgOption ("filename" , "Name of the output file.\n Default: javadoc.xml" ),
38
+ newOneArgOption ("basePackage" , "Name of the base package.\n " ),
39
+ newOneArgOption ("doctitle" , "Document Title\n " ),
40
+ newOneArgOption ("windowtitle" , "Window Title\n " ),
41
+ newNoArgOption ("noTimestamp" , "No Timestamp.\n " ),
42
+ newNoArgOption ("withFloatingToc" , "Renders a Floating TOC on the right side.\n " ));
44
43
}
45
44
46
45
public Set <CustomOption > get () {
@@ -49,6 +48,7 @@ public Set<CustomOption> get() {
49
48
50
49
/**
51
50
* Creates an option with one argument that has the same name of the option itself.
51
+ *
52
52
* @param optionName name of the option and its own single argument
53
53
* @param description option description
54
54
*/
@@ -58,6 +58,7 @@ private CustomOption newOneArgOption(final String optionName, final String descr
58
58
59
59
/**
60
60
* Creates an option with one argument.
61
+ *
61
62
* @param optionName name of the option
62
63
* @param argName name of the argument to be passed to the option, used in the help message
63
64
* @param description option description
@@ -67,55 +68,55 @@ private CustomOption newArgOption(final String optionName, final String argName,
67
68
}
68
69
69
70
private CustomOption newNoArgOption (final String optionName , final String description ) {
70
- return CustomOption .newNoArgs (optionName , description , this :: processNoArgValue );
71
+ return CustomOption .newNoArgs (optionName , description , ( optionName1 , argValues ) -> processNoArgValue ( optionName1 ) );
71
72
}
72
73
73
74
/**
74
75
* Process and stores name of the option in the {@link #givenCliOptionsMap} to indicate it was sucessfully
75
76
* processed (since it has no arguments and no validation is required).
77
+ *
76
78
* @param optionName name of the option to store the argument value
77
- * @param argValues list of arguments values for the option, which will be empty and ignored,
78
- * since the option doesn't expect any argument.
79
79
* @return true to indicate the option was successfully processed.
80
80
*/
81
- private boolean processNoArgValue (final String optionName , final List < String > argValues ) {
81
+ private boolean processNoArgValue (final String optionName ) {
82
82
givenCliOptionsMap .put (addHyphenPrefix (optionName ), null );
83
83
return true ;
84
84
}
85
85
86
86
/**
87
87
* Process and stores the first argument value passed in the command line for a given option
88
88
* when that option is being processed by {@link CustomOption#process(String, List)}.
89
+ *
89
90
* @param optionName name of the option to store the argument value
90
91
* @param argValues list of arguments to get the first value to store
91
92
* @return true if there was one argument value in the argument list, false otherwise, indicating no value was stored
92
93
*/
93
- private boolean processFirstArgValue (final String optionName , final List <String > argValues ){
94
- if (argValues .isEmpty ()){
94
+ private boolean processFirstArgValue (final String optionName , final List <String > argValues ) {
95
+ if (argValues .isEmpty ()) {
95
96
return false ;
96
97
}
97
98
98
- givenCliOptionsMap .put (addHyphenPrefix (optionName ), argValues .getFirst ( ));
99
+ givenCliOptionsMap .put (addHyphenPrefix (optionName ), argValues .get ( 0 ));
99
100
return true ;
100
101
}
101
102
102
- public boolean hasOption (final String optionName ){
103
+ public boolean hasOption (final String optionName ) {
103
104
return givenCliOptionsMap .containsKey (addHyphenPrefix (optionName ));
104
105
}
105
106
106
- public String getOptionValue (final CustomOption option ){
107
+ public String getOptionValue (final CustomOption option ) {
107
108
return getOptionValue (option .getName ());
108
109
}
109
110
110
- public String getOptionValue (final String optionName ){
111
+ public String getOptionValue (final String optionName ) {
111
112
return getOptionValue (optionName , "" );
112
113
}
113
114
114
- public String getOptionValue (final CustomOption option , final String defaultValue ){
115
+ public String getOptionValue (final CustomOption option , final String defaultValue ) {
115
116
return getOptionValue (option .getName (), defaultValue );
116
117
}
117
118
118
- public String getOptionValue (final String optionName , final String defaultValue ){
119
+ public String getOptionValue (final String optionName , final String defaultValue ) {
119
120
return givenCliOptionsMap .getOrDefault (addHyphenPrefix (optionName ), defaultValue );
120
121
}
121
122
0 commit comments