Skip to content

Commit bf19d99

Browse files
committed
Use final.
1 parent a3e2d6b commit bf19d99

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/org/apache/commons/cli/DefaultParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class DefaultParser implements CommandLineParser
5555
protected List expectedOpts;
5656

5757
/** Flag indicating if partial matching of long options is supported. */
58-
private boolean allowPartialMatching;
58+
private final boolean allowPartialMatching;
5959

6060
/**
6161
* Creates a new DefaultParser instance with partial matching enabled.
@@ -718,10 +718,10 @@ private List<String> getMatchingLongOptions(final String token)
718718
}
719719
else
720720
{
721-
List<String> matches = new ArrayList<>(1);
721+
final List<String> matches = new ArrayList<>(1);
722722
if (options.hasLongOption(token))
723723
{
724-
Option option = options.getOption(token);
724+
final Option option = options.getOption(token);
725725
matches.add(option.getLongOpt());
726726
}
727727

src/main/java/org/apache/commons/cli/TypeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static File createFile(final String str)
231231
* @return The file input stream represented by <code>str</code>.
232232
* @throws ParseException if the file is not exist or not readable
233233
*/
234-
public static FileInputStream openFile(String str) throws ParseException
234+
public static FileInputStream openFile(final String str) throws ParseException
235235
{
236236
try
237237
{

src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public class DisablePartialMatchingTest
2727
@Test
2828
public void testDisablePartialMatching() throws Exception
2929
{
30-
CommandLineParser parser = new DefaultParser(false);
30+
final CommandLineParser parser = new DefaultParser(false);
3131

3232
final Options options = new Options();
3333

3434
options.addOption(new Option("d", "debug", false, "Turn on debug."));
3535
options.addOption(new Option("e", "extract", false, "Turn on extract."));
3636
options.addOption(new Option("o", "option", true, "Turn on option with argument."));
3737

38-
CommandLine line = parser.parse(options, new String[]{"-de", "--option=foobar"});
38+
final CommandLine line = parser.parse(options, new String[]{"-de", "--option=foobar"});
3939

4040
assertTrue("There should be an option debug in any case...", line.hasOption("debug"));
4141
assertTrue("There should be an extract option because partial matching is off", line.hasOption("extract"));

src/test/java/org/apache/commons/cli/TypeHandlerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void testCreateValueObject_notInstantiableClass()
5555
public void testCreateValueObject_InstantiableClass()
5656
throws Exception
5757
{
58-
Object result = TypeHandler.createValue(Instantiable.class.getName(), PatternOptionBuilder.OBJECT_VALUE);
58+
final Object result = TypeHandler.createValue(Instantiable.class.getName(), PatternOptionBuilder.OBJECT_VALUE);
5959
assertTrue(result instanceof Instantiable);
6060
}
6161

@@ -98,23 +98,23 @@ public void testCreateValueClass_notFound()
9898
public void testCreateValueClass()
9999
throws Exception
100100
{
101-
Object clazz = TypeHandler.createValue(Instantiable.class.getName(), PatternOptionBuilder.CLASS_VALUE);
101+
final Object clazz = TypeHandler.createValue(Instantiable.class.getName(), PatternOptionBuilder.CLASS_VALUE);
102102
assertEquals(Instantiable.class, clazz);
103103
}
104104

105105
@Test
106106
public void testCreateValueFile()
107107
throws Exception
108108
{
109-
File result = TypeHandler.createValue("some-file.txt", PatternOptionBuilder.FILE_VALUE);
109+
final File result = TypeHandler.createValue("some-file.txt", PatternOptionBuilder.FILE_VALUE);
110110
assertEquals("some-file.txt", result.getName());
111111
}
112112

113113
@Test
114114
public void testCreateValueExistingFile()
115115
throws Exception
116116
{
117-
FileInputStream result = TypeHandler.createValue("src/test/resources/org/apache/commons/cli/existing-readable.file", PatternOptionBuilder.EXISTING_FILE_VALUE);
117+
final FileInputStream result = TypeHandler.createValue("src/test/resources/org/apache/commons/cli/existing-readable.file", PatternOptionBuilder.EXISTING_FILE_VALUE);
118118
assertNotNull(result);
119119
}
120120

@@ -136,8 +136,8 @@ public void testCreateValueFiles()
136136
public void testCreateValueURL()
137137
throws Exception
138138
{
139-
String urlString = "https://commons.apache.org";
140-
URL result = TypeHandler.createValue(urlString, PatternOptionBuilder.URL_VALUE);
139+
final String urlString = "https://commons.apache.org";
140+
final URL result = TypeHandler.createValue(urlString, PatternOptionBuilder.URL_VALUE);
141141
assertEquals(urlString, result.toString());
142142
}
143143

0 commit comments

Comments
 (0)