This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
The following commit(s) were added to refs/heads/master by this push: new 1797df4 Use final. 1797df4 is described below commit 1797df4c93e0fd0c648ccabebbba120cd0966023 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu May 23 09:01:22 2019 -0400 Use final. --- .../configuration2/PropertiesConfiguration.java | 32 ++++++++--------- .../builder/INIBuilderParametersImpl.java | 4 +-- .../builder/INIBuilderProperties.java | 4 +-- .../interpol/StringLookupAdapter.java | 4 +-- .../configuration2/InterpolationTestHelper.java | 6 ++-- .../TestPropertiesConfiguration.java | 41 ++++++++++++---------- 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java index 751e99f..bcb4371 100644 --- a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java @@ -896,7 +896,7 @@ public class PropertiesConfiguration extends BaseConfiguration * @return the unescaped property name * @since 2.4 */ - protected String unescapePropertyName(String name) + protected String unescapePropertyName(final String name) { return StringEscapeUtils.unescapeJava(name); } @@ -922,7 +922,7 @@ public class PropertiesConfiguration extends BaseConfiguration * @return the unescaped property value * @since 2.4 */ - protected String unescapePropertyValue(String value) + protected String unescapePropertyValue(final String value) { return unescapeJava(value); } @@ -1066,7 +1066,7 @@ public class PropertiesConfiguration extends BaseConfiguration * with multiple values * @param valueTransformer the value transformer used to escape property values */ - public PropertiesWriter(Writer writer, ListDelimiterHandler delHandler, ValueTransformer valueTransformer) + public PropertiesWriter(final Writer writer, final ListDelimiterHandler delHandler, final ValueTransformer valueTransformer) { super(writer); delimiterHandler = delHandler; @@ -1456,19 +1456,19 @@ public class PropertiesConfiguration extends BaseConfiguration * * @param escapeUnicode whether Unicode characters should be escaped */ - public JupIOFactory(boolean escapeUnicode) + public JupIOFactory(final boolean escapeUnicode) { this.escapeUnicode = escapeUnicode; } @Override - public PropertiesReader createPropertiesReader(Reader in) + public PropertiesReader createPropertiesReader(final Reader in) { return new JupPropertiesReader(in); } @Override - public PropertiesWriter createPropertiesWriter(Writer out, ListDelimiterHandler handler) + public PropertiesWriter createPropertiesWriter(final Writer out, final ListDelimiterHandler handler) { return new JupPropertiesWriter(out, handler, escapeUnicode); } @@ -1489,7 +1489,7 @@ public class PropertiesConfiguration extends BaseConfiguration * * @param reader A Reader. */ - public JupPropertiesReader(Reader reader) + public JupPropertiesReader(final Reader reader) { super(reader); } @@ -1499,7 +1499,7 @@ public class PropertiesConfiguration extends BaseConfiguration public String readProperty() throws IOException { getCommentLines().clear(); - StringBuilder buffer = new StringBuilder(); + final StringBuilder buffer = new StringBuilder(); while (true) { @@ -1554,16 +1554,16 @@ public class PropertiesConfiguration extends BaseConfiguration } @Override - protected void parseProperty(String line) + protected void parseProperty(final String line) { - String[] property = doParseProperty(line, false); + final String[] property = doParseProperty(line, false); initPropertyName(property[0]); initPropertyValue(property[1]); initPropertySeparator(property[2]); } @Override - protected String unescapePropertyValue(String value) + protected String unescapePropertyValue(final String value) { return unescapeJava(value, true); } @@ -1585,7 +1585,7 @@ public class PropertiesConfiguration extends BaseConfiguration private static final Map<CharSequence, CharSequence> JUP_CHARS_ESCAPE; static { - Map<CharSequence, CharSequence> initialMap = new HashMap<>(); + final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); initialMap.put("\\", "\\\\"); initialMap.put("\n", "\\n"); initialMap.put("\t", "\\t"); @@ -1603,12 +1603,12 @@ public class PropertiesConfiguration extends BaseConfiguration * @param escapeUnicode whether Unicode characters should be escaped using * Unicode escapes */ - public JupPropertiesWriter(Writer writer, ListDelimiterHandler delHandler, final boolean escapeUnicode) + public JupPropertiesWriter(final Writer writer, final ListDelimiterHandler delHandler, final boolean escapeUnicode) { super(writer, delHandler, new ValueTransformer() { @Override - public Object transformValue(Object value) + public Object transformValue(final Object value) { String valueString = String.valueOf(value); @@ -1667,7 +1667,7 @@ public class PropertiesConfiguration extends BaseConfiguration * @return the processed string * @throws IllegalArgumentException if the Writer is {@code null} */ - protected static String unescapeJava(String str, boolean jupCompatible) + protected static String unescapeJava(final String str, final boolean jupCompatible) { if (str == null) { @@ -1797,7 +1797,7 @@ public class PropertiesConfiguration extends BaseConfiguration * @param optional whether or not the {@code fileName} is optional * @throws ConfigurationException if loading fails */ - private void loadIncludeFile(final String fileName, boolean optional) throws ConfigurationException + private void loadIncludeFile(final String fileName, final boolean optional) throws ConfigurationException { if (locator == null) { diff --git a/src/main/java/org/apache/commons/configuration2/builder/INIBuilderParametersImpl.java b/src/main/java/org/apache/commons/configuration2/builder/INIBuilderParametersImpl.java index 43c6481..2b90b12 100644 --- a/src/main/java/org/apache/commons/configuration2/builder/INIBuilderParametersImpl.java +++ b/src/main/java/org/apache/commons/configuration2/builder/INIBuilderParametersImpl.java @@ -62,13 +62,13 @@ public class INIBuilderParametersImpl extends HierarchicalBuilderParametersImpl } @Override - public INIBuilderParametersImpl setSeparatorUsedInInput(String separator) { + public INIBuilderParametersImpl setSeparatorUsedInInput(final String separator) { storeProperty(PROP_SEPARATOR_USED_IN_INI_INPUT, separator); return this; } @Override - public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(String separator) { + public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(final String separator) { storeProperty(PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT, separator); return this; } diff --git a/src/main/java/org/apache/commons/configuration2/builder/INIBuilderProperties.java b/src/main/java/org/apache/commons/configuration2/builder/INIBuilderProperties.java index 0571b8a..b196eb5 100644 --- a/src/main/java/org/apache/commons/configuration2/builder/INIBuilderProperties.java +++ b/src/main/java/org/apache/commons/configuration2/builder/INIBuilderProperties.java @@ -43,7 +43,7 @@ public interface INIBuilderProperties<T> { * @return a reference to this object for method chaining * @since 2.5 */ - default T setCommentLeadingCharsUsedInInput(String separator) { + default T setCommentLeadingCharsUsedInInput(final String separator) { // NoOp return (T) this; } @@ -56,7 +56,7 @@ public interface INIBuilderProperties<T> { * @return a reference to this object for method chaining * @since 2.5 */ - default T setSeparatorUsedInInput(String separator) { + default T setSeparatorUsedInInput(final String separator) { // NoOp return (T) this; } diff --git a/src/main/java/org/apache/commons/configuration2/interpol/StringLookupAdapter.java b/src/main/java/org/apache/commons/configuration2/interpol/StringLookupAdapter.java index b9bea49..74bf673 100644 --- a/src/main/java/org/apache/commons/configuration2/interpol/StringLookupAdapter.java +++ b/src/main/java/org/apache/commons/configuration2/interpol/StringLookupAdapter.java @@ -29,13 +29,13 @@ class StringLookupAdapter implements Lookup { private final StringLookup stringLookup; - StringLookupAdapter(StringLookup stringLookup) { + StringLookupAdapter(final StringLookup stringLookup) { super(); this.stringLookup = Objects.requireNonNull(stringLookup, "stringLookup"); } @Override - public Object lookup(String key) { + public Object lookup(final String key) { return stringLookup.lookup(key); } diff --git a/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java b/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java index 1e89891..240d8e5 100644 --- a/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java +++ b/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java @@ -188,9 +188,9 @@ public class InterpolationTestHelper * * @param config the configuration to test */ - public static void testInterpolationLocalhost(Configuration config) + public static void testInterpolationLocalhost(final Configuration config) { - String[] localhostKeys = + final String[] localhostKeys = { "name", "canonical-name", "address" }; String[] localhostValues = null; try { @@ -198,7 +198,7 @@ public class InterpolationTestHelper InetAddress.getLocalHost().getHostName(), InetAddress.getLocalHost().getCanonicalHostName(), InetAddress.getLocalHost().getHostAddress() }; - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { Assert.fail(e); } for (int i = 0; i < localhostKeys.length; i++) diff --git a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java index 89295ce..dd63ff5 100644 --- a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java +++ b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java @@ -734,23 +734,24 @@ public class TestPropertiesConfiguration conf.clear(); conf.setIOFactory(new PropertiesConfiguration.JupIOFactory()); - String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); + final String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); load(conf, testFilePath); - Properties jup = new Properties(); + final Properties jup = new Properties(); try (InputStream in = Files.newInputStream(Paths.get(testFilePath))) { jup.load(in); } @SuppressWarnings("unchecked") + final Set<Object> pcKeys = new HashSet<>(IteratorUtils.toList(conf.getKeys())); assertEquals(jup.keySet(), pcKeys); - for (Object key : jup.keySet()) + for (final Object key : jup.keySet()) { - String keyString = key.toString(); + final String keyString = key.toString(); System.out.println(keyString); assertEquals("Wrong property value for '" + keyString + "'", jup.getProperty(keyString), conf.getProperty(keyString)); @@ -767,17 +768,17 @@ public class TestPropertiesConfiguration conf.clear(); conf.setIOFactory(new PropertiesConfiguration.JupIOFactory()); - String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); + final String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); // read the test properties and set them on the PropertiesConfiguration - Properties origProps = new Properties(); + final Properties origProps = new Properties(); try (InputStream in = Files.newInputStream(Paths.get(testFilePath))) { origProps.load(in); } - for (Object key : origProps.keySet()) + for (final Object key : origProps.keySet()) { - String keyString = key.toString(); + final String keyString = key.toString(); conf.setProperty(keyString, origProps.getProperty(keyString)); } @@ -786,7 +787,7 @@ public class TestPropertiesConfiguration assertTrue("The saved file doesn't exist", testSavePropertiesFile.exists()); // load the saved file... - Properties testProps = new Properties(); + final Properties testProps = new Properties(); try (InputStream in = Files.newInputStream(testSavePropertiesFile.toPath())) { testProps.load(in); @@ -794,12 +795,13 @@ public class TestPropertiesConfiguration // ... and compare the properties to the originals @SuppressWarnings("unchecked") + final Set<Object> pcKeys = new HashSet<>(IteratorUtils.toList(conf.getKeys())); assertEquals(testProps.keySet(), pcKeys); - for (Object key : testProps.keySet()) + for (final Object key : testProps.keySet()) { - String keyString = key.toString(); + final String keyString = key.toString(); assertEquals("Wrong property value for '" + keyString + "'", testProps.getProperty(keyString), conf.getProperty(keyString)); } @@ -816,17 +818,17 @@ public class TestPropertiesConfiguration conf.clear(); conf.setIOFactory(new PropertiesConfiguration.JupIOFactory(false)); - String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); + final String testFilePath = ConfigurationAssert.getTestFile("jup-test.properties").getAbsolutePath(); // read the test properties and set them on the PropertiesConfiguration - Properties origProps = new Properties(); + final Properties origProps = new Properties(); try (InputStream in = Files.newInputStream(Paths.get(testFilePath))) { origProps.load(in); } - for (Object key : origProps.keySet()) + for (final Object key : origProps.keySet()) { - String keyString = key.toString(); + final String keyString = key.toString(); conf.setProperty(keyString, origProps.getProperty(keyString)); } @@ -837,7 +839,7 @@ public class TestPropertiesConfiguration assertTrue("The saved file doesn't exist", testSavePropertiesFile.exists()); // load the saved file... - Properties testProps = new Properties(); + final Properties testProps = new Properties(); try (BufferedReader in = Files.newBufferedReader(testSavePropertiesFile.toPath(), StandardCharsets.UTF_8)) { testProps.load(in); @@ -845,18 +847,19 @@ public class TestPropertiesConfiguration // ... and compare the properties to the originals @SuppressWarnings("unchecked") + final Set<Object> pcKeys = new HashSet<>(IteratorUtils.toList(conf.getKeys())); assertEquals(testProps.keySet(), pcKeys); - for (Object key : testProps.keySet()) + for (final Object key : testProps.keySet()) { - String keyString = key.toString(); + final String keyString = key.toString(); assertEquals("Wrong property value for '" + keyString + "'", testProps.getProperty(keyString), conf.getProperty(keyString)); } // ensure that the written properties file contains no Unicode escapes - for (String line : Files.readAllLines(testSavePropertiesFile.toPath())) + for (final String line : Files.readAllLines(testSavePropertiesFile.toPath())) { if (line.contains("\\u")) {