2020import java .util .ArrayList ;
2121import java .util .Arrays ;
2222import java .util .Enumeration ;
23- import java .util .Iterator ;
2423import java .util .List ;
2524import java .util .ListIterator ;
2625import java .util .Properties ;
@@ -140,20 +139,15 @@ public CommandLine parse(Options options, String[] arguments, boolean stopAtNonO
140139 *
141140 * @since 1.1
142141 */
143- public CommandLine parse (Options options , String [] arguments , Properties properties , boolean stopAtNonOption )
144- throws ParseException
142+ public CommandLine parse (Options options , String [] arguments , Properties properties , boolean stopAtNonOption ) throws ParseException
145143 {
146144 // clear out the data in options in case it's been used before (CLI-71)
147- for (Iterator it = options .helpOptions ().iterator (); it .hasNext ();)
148- {
149- Option opt = (Option ) it .next ();
145+ for (Option opt : options .helpOptions ()) {
150146 opt .clearValues ();
151147 }
152148
153149 // clear the data from the groups
154- for (Iterator it = options .getOptionGroups ().iterator (); it .hasNext ();)
155- {
156- OptionGroup group = (OptionGroup ) it .next ();
150+ for (OptionGroup group : options .getOptionGroups ()) {
157151 group .setSelected (null );
158152 }
159153
@@ -169,14 +163,14 @@ public CommandLine parse(Options options, String[] arguments, Properties propert
169163 arguments = new String [0 ];
170164 }
171165
172- List tokenList = Arrays .asList (flatten (getOptions (), arguments , stopAtNonOption ));
166+ List < String > tokenList = Arrays .asList (flatten (getOptions (), arguments , stopAtNonOption ));
173167
174- ListIterator iterator = tokenList .listIterator ();
168+ ListIterator < String > iterator = tokenList .listIterator ();
175169
176170 // process each flattened token
177171 while (iterator .hasNext ())
178172 {
179- String t = ( String ) iterator .next ();
173+ String t = iterator .next ();
180174
181175 // the value is the double-dash
182176 if ("--" .equals (t ))
@@ -227,7 +221,7 @@ else if (t.startsWith("-"))
227221 {
228222 while (iterator .hasNext ())
229223 {
230- String str = ( String ) iterator .next ();
224+ String str = iterator .next ();
231225
232226 // ensure only one double-dash is added
233227 if (!"--" .equals (str ))
@@ -308,8 +302,7 @@ else if (!("yes".equalsIgnoreCase(value)
308302 * Throws a {@link MissingOptionException} if all of the required options
309303 * are not present.
310304 *
311- * @throws MissingOptionException if any of the required Options
312- * are not present.
305+ * @throws MissingOptionException if any of the required Options are not present.
313306 */
314307 protected void checkRequiredOptions () throws MissingOptionException
315308 {
@@ -321,24 +314,23 @@ protected void checkRequiredOptions() throws MissingOptionException
321314 }
322315
323316 /**
324- * <p> Process the argument values for the specified Option
317+ * Process the argument values for the specified Option
325318 * <code>opt</code> using the values retrieved from the
326319 * specified iterator <code>iter</code>.
327320 *
328321 * @param opt The current Option
329- * @param iter The iterator over the flattened command line
330- * Options.
322+ * @param iter The iterator over the flattened command line Options.
331323 *
332324 * @throws ParseException if an argument value is required
333325 * and it is has not been found.
334326 */
335- public void processArgs (Option opt , ListIterator iter ) throws ParseException
327+ public void processArgs (Option opt , ListIterator < String > iter ) throws ParseException
336328 {
337329 // loop until an option is found
338330 while (iter .hasNext ())
339331 {
340- String str = ( String ) iter .next ();
341-
332+ String str = iter .next ();
333+
342334 // found an Option, not an argument
343335 if (getOptions ().hasOption (str ) && str .startsWith ("-" ))
344336 {
@@ -373,7 +365,7 @@ public void processArgs(Option opt, ListIterator iter) throws ParseException
373365 *
374366 * @throws ParseException if <code>arg</code> does not represent an Option
375367 */
376- protected void processOption (String arg , ListIterator iter ) throws ParseException
368+ protected void processOption (String arg , ListIterator < String > iter ) throws ParseException
377369 {
378370 boolean hasOption = getOptions ().hasOption (arg );
379371
@@ -384,7 +376,7 @@ protected void processOption(String arg, ListIterator iter) throws ParseExceptio
384376 }
385377
386378 // get the option represented by arg
387- Option opt = ( Option ) getOptions ().getOption (arg ).clone ();
379+ Option opt = getOptions ().getOption (arg ).clone ();
388380
389381 // update the required options and groups
390382 updateRequiredOptions (opt );
0 commit comments