@@ -39,7 +39,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
3939
4040public class CommandLineTest {
4141
42- private enum Count { ONE , TWO , THREE };
42+ private enum Count { ONE , TWO , THREE }
4343
4444 @ Test
4545 public void testBuilder () {
@@ -198,18 +198,16 @@ public void noDeprecationHandlerTest(final String[] args, final Option opt, fina
198198 final String optValue , final boolean grpDep , final String grpValue , final Option grpOpt ) throws ParseException {
199199 final Options options = new Options ().addOptionGroup (optionGroup );
200200 final CommandLine commandLine = DefaultParser .builder ().build ().parse (options , args );
201- final Supplier <String > thinger = () -> {
202- return "thing" ;
203- };
201+ final Supplier <String > thinger = () -> "thing" ;
204202 final Supplier <String > nullSupplier = null ;
205203 final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
206- PrintStream ps = System .out ;
204+ final PrintStream ps = System .out ;
207205 try {
208206 System .setOut (new PrintStream (baos ));
209207
210- OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
208+ final OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
211209 .addOption (Option .builder ().option ("p" ).longOpt ("part" ).hasArg ().build ());
212- OptionGroup nullGroup = null ;
210+ final OptionGroup nullGroup = null ;
213211
214212 // test char option
215213 assertEquals (optValue , commandLine .getOptionValue (asChar (opt )));
@@ -359,12 +357,10 @@ public void getOptionValueTest(final String[] args, final Option opt, final Opti
359357 final Options options = new Options ().addOptionGroup (optionGroup );
360358 final List <Option > handler = new ArrayList <>();
361359 final CommandLine commandLine = DefaultParser .builder ().setDeprecatedHandler (handler ::add ).build ().parse (options , args );
362- final Supplier <String > thinger = () -> {
363- return "thing" ;
364- };
365- OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
360+ final Supplier <String > thinger = () -> "thing" ;
361+ final OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
366362 .addOption (Option .builder ().option ("p" ).longOpt ("part" ).hasArg ().build ());
367- OptionGroup nullGroup = null ;
363+ final OptionGroup nullGroup = null ;
368364
369365 // test char option
370366 assertEquals (optValue , commandLine .getOptionValue (asChar (opt )));
@@ -448,10 +444,10 @@ public void getOptionValueTest(final String[] args, final Option opt, final Opti
448444 }
449445
450446 private static Stream <Arguments > createOptionValueParameters () throws ParseException {
451- List <Arguments > lst = new ArrayList <>();
447+ final List <Arguments > lst = new ArrayList <>();
452448 final Option optT = Option .builder ().option ("T" ).longOpt ("tee" ).deprecated ().optionalArg (true ).build ();
453449 final Option optU = Option .builder ("U" ).longOpt ("you" ).optionalArg (true ).build ();
454- OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
450+ final OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
455451
456452 // T set
457453 lst .add (Arguments .of (new String [] {"-T" }, optT , optionGroup , true , null , true , null , optT ));
@@ -500,9 +496,9 @@ public void getOptionValuesTest(final String[] args, final Option opt, final Opt
500496 final Options options = new Options ().addOptionGroup (optionGroup );
501497 final List <Option > handler = new ArrayList <>();
502498 final CommandLine commandLine = DefaultParser .builder ().setDeprecatedHandler (handler ::add ).build ().parse (options , args );
503- OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
499+ final OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
504500 .addOption (Option .builder ().option ("p" ).longOpt ("part" ).hasArg ().build ());
505- OptionGroup nullGroup = null ;
501+ final OptionGroup nullGroup = null ;
506502
507503 // test char option arg
508504 assertArrayEquals (optValue , commandLine .getOptionValues (asChar (opt )));
@@ -539,12 +535,12 @@ public void getOptionValuesTest(final String[] args, final Option opt, final Opt
539535 }
540536
541537 private static Stream <Arguments > createOptionValuesParameters () throws ParseException {
542- List <Arguments > lst = new ArrayList <>();
538+ final List <Arguments > lst = new ArrayList <>();
543539 final Option optT = Option .builder ().option ("T" ).longOpt ("tee" ).numberOfArgs (2 ).deprecated ().optionalArg (true ).build ();
544540 final Option optU = Option .builder ("U" ).longOpt ("you" ).numberOfArgs (2 ).optionalArg (true ).build ();
545541 final OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
546542
547- String [] foobar = { "foo" , "bar" };
543+ final String [] foobar = { "foo" , "bar" };
548544 // T set
549545 lst .add (Arguments .of (new String [] {"-T" }, optT , optionGroup , true , null , true , null , optT ));
550546 lst .add (Arguments .of (new String [] {"-T" , "foo" , "bar" }, optT , optionGroup , true , foobar , true , foobar , optT ));
@@ -647,7 +643,7 @@ public void hasOptionNoDeprecationHandlerTest(final String[] args, final Option
647643 final Options options = new Options ().addOptionGroup (optionGroup );
648644 final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
649645 final CommandLine commandLine = DefaultParser .builder ().build ().parse (options , args );
650- PrintStream ps = System .out ;
646+ final PrintStream ps = System .out ;
651647 try {
652648 System .setOut (new PrintStream (baos ));
653649
@@ -699,7 +695,7 @@ public void hasOptionNullDeprecationHandlerTest(final String[] args, final Optio
699695 final Options options = new Options ().addOptionGroup (optionGroup );
700696 final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
701697 final CommandLine commandLine = DefaultParser .builder ().setDeprecatedHandler (null ).build ().parse (options , args );
702- PrintStream ps = System .out ;
698+ final PrintStream ps = System .out ;
703699 try {
704700 System .setOut (new PrintStream (baos ));
705701
@@ -733,12 +729,12 @@ public void hasOptionNullDeprecationHandlerTest(final String[] args, final Optio
733729 }
734730
735731 private static Stream <Arguments > createHasOptionParameters () throws ParseException {
736- List <Arguments > lst = new ArrayList <>();
732+ final List <Arguments > lst = new ArrayList <>();
737733 final Option optT = Option .builder ().option ("T" ).longOpt ("tee" ).deprecated ().optionalArg (true ).build ();
738734 final Option optU = Option .builder ("U" ).longOpt ("you" ).optionalArg (true ).build ();
739735 final OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
740736
741- String [] foobar = { "foo" , "bar" };
737+ final String [] foobar = { "foo" , "bar" };
742738 // T set
743739 lst .add (Arguments .of (new String [] {"-T" }, optT , optionGroup , true , true , true , true , optT ));
744740 lst .add (Arguments .of (new String [] {"-T" , "foo" }, optT , optionGroup , true , true , true , true , optT ));
@@ -772,13 +768,11 @@ public void getParsedOptionValueTest(final String[] args, final Option opt, fina
772768 final Options options = new Options ().addOptionGroup (optionGroup );
773769 final List <Option > handler = new ArrayList <>();
774770 final CommandLine commandLine = DefaultParser .builder ().setDeprecatedHandler (handler ::add ).build ().parse (options , args );
775- final Supplier <Integer > thinger = () -> {
776- return 2 ;
777- };
778- OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
771+ final Supplier <Integer > thinger = () -> 2 ;
772+ final OptionGroup otherGroup = new OptionGroup ().addOption (Option .builder ("o" ).longOpt ("other" ).hasArg ().build ())
779773 .addOption (Option .builder ().option ("p" ).longOpt ("part" ).hasArg ().build ());
780- OptionGroup nullGroup = null ;
781- Integer thing = 2 ;
774+ final OptionGroup nullGroup = null ;
775+ final Integer thing = 2 ;
782776
783777 // test char option arg
784778 assertEquals (optValue , commandLine .getParsedOptionValue (asChar (opt )));
@@ -864,11 +858,11 @@ public void getParsedOptionValueTest(final String[] args, final Option opt, fina
864858 }
865859
866860 private static Stream <Arguments > createParsedOptionValueParameters () throws ParseException {
867- List <Arguments > lst = new ArrayList <>();
868- Option optT = Option .builder ().option ("T" ).longOpt ("tee" ).deprecated ().type (Integer .class ).optionalArg (true ).build ();
869- Option optU = Option .builder ("U" ).longOpt ("you" ).type (Integer .class ).optionalArg (true ).build ();
870- OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
871- Integer expected = Integer .valueOf (1 );
861+ final List <Arguments > lst = new ArrayList <>();
862+ final Option optT = Option .builder ().option ("T" ).longOpt ("tee" ).deprecated ().type (Integer .class ).optionalArg (true ).build ();
863+ final Option optU = Option .builder ("U" ).longOpt ("you" ).type (Integer .class ).optionalArg (true ).build ();
864+ final OptionGroup optionGroup = new OptionGroup ().addOption (optT ).addOption (optU );
865+ final Integer expected = Integer .valueOf (1 );
872866
873867 // T set
874868 lst .add (Arguments .of (new String [] {"-T" }, optT , optionGroup , true , null , true , null , optT ));
0 commit comments