You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/09/30 14:41:55 UTC
[commons-configuration] branch master updated: [CONFIGURATION-762]
Use variable arguments.
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 a758257 [CONFIGURATION-762] Use variable arguments.
a758257 is described below
commit a758257bdac4bbb7e03c3607f835e5c8f535ef5e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 30 10:41:51 2019 -0400
[CONFIGURATION-762] Use variable arguments.
---
src/changes/changes.xml | 3 +++
.../commons/configuration2/DataConfiguration.java | 30 +++++++++++-----------
.../BuilderConfigurationWrapperFactory.java | 2 +-
.../spring/ConfigurationPropertiesFactoryBean.java | 4 +--
.../TestConfigurationPropertiesFactoryBean.java | 16 +++---------
5 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7e7c701..14acd97 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
<action dev="ggregory" type="fix" issue="CONFIGURATION-761" due-to="Gary Gregory">
Single argument DataConfiguration APIs always create empty arrays.
</action>
+ <action dev="ggregory" type="update" issue="CONFIGURATION-762" due-to="Gary Gregory">
+ Use variable arguments.
+ </action>
</release>
<release version="2.6" date="2019-09-13"
description="Minor release with new features and updated dependencies.">
diff --git a/src/main/java/org/apache/commons/configuration2/DataConfiguration.java b/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
index 27445f1..d1fde35 100644
--- a/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
+++ b/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
@@ -286,7 +286,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of booleans.
*/
- public boolean[] getBooleanArray(final String key, final boolean[] defaultValue)
+ public boolean[] getBooleanArray(final String key, final boolean... defaultValue)
{
return get(boolean[].class, key, defaultValue);
}
@@ -351,7 +351,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of bytes.
*/
- public byte[] getByteArray(final String key, final byte[] defaultValue)
+ public byte[] getByteArray(final String key, final byte... defaultValue)
{
return get(byte[].class, key, defaultValue);
}
@@ -416,7 +416,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of shorts.
*/
- public short[] getShortArray(final String key, final short[] defaultValue)
+ public short[] getShortArray(final String key, final short... defaultValue)
{
return get(short[].class, key, defaultValue);
}
@@ -482,7 +482,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of integers.
*/
- public int[] getIntArray(final String key, final int[] defaultValue)
+ public int[] getIntArray(final String key, final int... defaultValue)
{
return get(int[].class, key, defaultValue);
}
@@ -547,7 +547,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of longs.
*/
- public long[] getLongArray(final String key, final long[] defaultValue)
+ public long[] getLongArray(final String key, final long... defaultValue)
{
return get(long[].class, key, defaultValue);
}
@@ -612,7 +612,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of floats.
*/
- public float[] getFloatArray(final String key, final float[] defaultValue)
+ public float[] getFloatArray(final String key, final float... defaultValue)
{
return get(float[].class, key, defaultValue);
}
@@ -678,7 +678,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of doubles.
*/
- public double[] getDoubleArray(final String key, final double[] defaultValue)
+ public double[] getDoubleArray(final String key, final double... defaultValue)
{
return get(double[].class, key, defaultValue);
}
@@ -743,7 +743,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of BigIntegers.
*/
- public BigInteger[] getBigIntegerArray(final String key, final BigInteger[] defaultValue)
+ public BigInteger[] getBigIntegerArray(final String key, final BigInteger... defaultValue)
{
return get(BigInteger[].class, key, defaultValue);
}
@@ -808,7 +808,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of BigDecimals.
*/
- public BigDecimal[] getBigDecimalArray(final String key, final BigDecimal[] defaultValue)
+ public BigDecimal[] getBigDecimalArray(final String key, final BigDecimal... defaultValue)
{
return get(BigDecimal[].class, key, defaultValue);
}
@@ -870,7 +870,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of URIs.
*/
- public URI[] getURIArray(final String key, final URI[] defaultValue)
+ public URI[] getURIArray(final String key, final URI... defaultValue)
{
return get(URI[].class, key, defaultValue);
}
@@ -996,7 +996,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of URLs.
*/
- public URL[] getURLArray(final String key, final URL[] defaultValue)
+ public URL[] getURLArray(final String key, final URL... defaultValue)
{
return get(URL[].class, key, defaultValue);
}
@@ -1212,7 +1212,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of Dates.
*/
- public Date[] getDateArray(final String key, final Date[] defaultValue)
+ public Date[] getDateArray(final String key, final Date... defaultValue)
{
return getDateArray(key, defaultValue, null);
}
@@ -1469,7 +1469,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of Calendars.
*/
- public Calendar[] getCalendarArray(final String key, final Calendar[] defaultValue)
+ public Calendar[] getCalendarArray(final String key, final Calendar... defaultValue)
{
return getCalendarArray(key, defaultValue, null);
}
@@ -1603,7 +1603,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of Locales.
*/
- public Locale[] getLocaleArray(final String key, final Locale[] defaultValue)
+ public Locale[] getLocaleArray(final String key, final Locale... defaultValue)
{
return get(Locale[].class, key, defaultValue);
}
@@ -1699,7 +1699,7 @@ public class DataConfiguration extends AbstractConfiguration
* @throws ConversionException is thrown if the key maps to an
* object that is not a list of Colors.
*/
- public Color[] getColorArray(final String key, final Color[] defaultValue)
+ public Color[] getColorArray(final String key, final Color... defaultValue)
{
return get(Color[].class, key, defaultValue);
}
diff --git a/src/main/java/org/apache/commons/configuration2/builder/BuilderConfigurationWrapperFactory.java b/src/main/java/org/apache/commons/configuration2/builder/BuilderConfigurationWrapperFactory.java
index 61c611e..00fa483 100644
--- a/src/main/java/org/apache/commons/configuration2/builder/BuilderConfigurationWrapperFactory.java
+++ b/src/main/java/org/apache/commons/configuration2/builder/BuilderConfigurationWrapperFactory.java
@@ -297,7 +297,7 @@ public class BuilderConfigurationWrapperFactory
* @return the return value of the method
* @throws Exception if an error occurs
*/
- private Object handleEventSourceInvocation(final Method method, final Object[] args)
+ private Object handleEventSourceInvocation(final Method method, final Object... args)
throws Exception
{
final Object target =
diff --git a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertiesFactoryBean.java b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertiesFactoryBean.java
index d478e6a..9c48fd5 100644
--- a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertiesFactoryBean.java
+++ b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertiesFactoryBean.java
@@ -143,7 +143,7 @@ public class ConfigurationPropertiesFactoryBean implements InitializingBean, Fac
*
* @param configurations commons configurations objects which will be used as properties.
*/
- public void setConfigurations(final Configuration[] configurations)
+ public void setConfigurations(final Configuration... configurations)
{
this.configurations = defensiveCopy(configurations);
}
@@ -160,7 +160,7 @@ public class ConfigurationPropertiesFactoryBean implements InitializingBean, Fac
*
* @param locations resources of configuration files
*/
- public void setLocations(final Resource[] locations)
+ public void setLocations(final Resource... locations)
{
this.locations = defensiveCopy(locations);
}
diff --git a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertiesFactoryBean.java b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertiesFactoryBean.java
index 9bfa370..cc518bc 100644
--- a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertiesFactoryBean.java
+++ b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertiesFactoryBean.java
@@ -56,9 +56,7 @@ public class TestConfigurationPropertiesFactoryBean
@Test
public void testGetObject() throws Exception
{
- configurationFactory.setConfigurations(new Configuration[] {
- new BaseConfiguration()
- });
+ configurationFactory.setConfigurations(new BaseConfiguration());
Assert.assertNull(configurationFactory.getObject());
configurationFactory.afterPropertiesSet();
Assert.assertNotNull(configurationFactory.getObject());
@@ -77,9 +75,7 @@ public class TestConfigurationPropertiesFactoryBean
new PropertiesConfigurationLayout();
layout.load(two, new StringReader(properties));
- configurationFactory.setConfigurations(new Configuration[] {
- one, two
- });
+ configurationFactory.setConfigurations(one, two);
configurationFactory.afterPropertiesSet();
final Properties props = configurationFactory.getObject();
Assert.assertEquals("foo", props.getProperty("bar"));
@@ -89,12 +85,8 @@ public class TestConfigurationPropertiesFactoryBean
@Test
public void testLoadResources() throws Exception
{
- configurationFactory.setLocations(new Resource[] {
- new ClassPathResource("testConfigurationFactoryBean.file")
- });
- configurationFactory.setConfigurations(new Configuration[] {
- new BaseConfiguration()
- });
+ configurationFactory.setLocations(new ClassPathResource("testConfigurationFactoryBean.file"));
+ configurationFactory.setConfigurations(new BaseConfiguration());
configurationFactory.afterPropertiesSet();
final Properties props = configurationFactory.getObject();