commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1643922 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration2/BaseConfiguration.java test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
Date Mon, 08 Dec 2014 21:04:49 GMT
Author: oheger
Date: Mon Dec  8 21:04:49 2014
New Revision: 1643922

URL: http://svn.apache.org/r1643922
Log:
[CONFIGURATION-200] Provided a specialized size() implementation for BaseConfiguration.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/BaseConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/BaseConfiguration.java?rev=1643922&r1=1643921&r2=1643922&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/BaseConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/BaseConfiguration.java
Mon Dec  8 21:04:49 2014
@@ -146,6 +146,16 @@ public class BaseConfiguration extends A
     }
 
     /**
+     * {@inheritDoc} This implementation obtains the size directly from the map
+     * used as data store. So this is a rather efficient implementation.
+     */
+    @Override
+    protected int sizeInternal()
+    {
+        return store.size();
+    }
+
+    /**
      * Get the list of the keys contained in the configuration
      * repository.
      *

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java?rev=1643922&r1=1643921&r2=1643922&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
Mon Dec  8 21:04:49 2014
@@ -762,4 +762,18 @@ public class TestBaseConfiguration
         assertEquals("Wrong interpolation in clone", "The answer is 43.",
                 clone.getString(keyAnswer));
     }
+
+    /**
+     * Tests the specific size() implementation.
+     */
+    @Test
+    public void testSize()
+    {
+        final int count = 16;
+        for (int i = 0; i < count; i++)
+        {
+            config.addProperty("key" + i, "value" + i);
+        }
+        assertEquals("Wrong size", count, config.size());
+    }
 }



Mime
View raw message