diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index df4f0a6eb..55100914c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -81,7 +81,7 @@ New classes o [COLLECTIONS-241] PassiveExpiringMap - map decorator which passively expires entries. Thanks to Elifarley Callado Coelho. o [COLLECTIONS-8 ] ComparatorPredicate - predicate to compare objects against a fixed instance. Thanks to Rune Peter Bjørnstad. o [None ] Put / Get - interfaces for split maps - o [None ] SplitMapUtils / splitmap.TransformedMap - utilities and implementation for split maps + o [None ] SplitMapUtils / splitmap.TransformedSplitMap - utilities and implementation for split maps New methods in *Utils diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 576e01086..f7bb41986 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -25,6 +25,10 @@ Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately after a difference has been found. + + + Renamed class "TransformedMap" in package "splitmap" to "TransformedSplitMap" to avoid + name clash with similar class in package "map". Replaced "Collection" with "Iterable" for method arguments where applicable. diff --git a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java index fd5755476..c1244abc1 100644 --- a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java @@ -40,7 +40,7 @@ import org.apache.commons.collections4.Transformer; *

* This class is Serializable from Commons Collections 3.1. *

- * @see org.apache.commons.collections4.splitmap.TransformedMap + * @see org.apache.commons.collections4.splitmap.TransformedSplitMap * * @since 3.0 * @version $Id$ diff --git a/src/main/java/org/apache/commons/collections4/splitmap/TransformedMap.java b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java similarity index 95% rename from src/main/java/org/apache/commons/collections4/splitmap/TransformedMap.java rename to src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java index 8d1384435..90dfc1e81 100644 --- a/src/main/java/org/apache/commons/collections4/splitmap/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java @@ -58,7 +58,7 @@ import org.apache.commons.collections4.map.LinkedMap; * @see org.apache.commons.collections4.SplitMapUtils#readableMap(Get) * @see org.apache.commons.collections4.SplitMapUtils#writableMap(Put) */ -public class TransformedMap extends AbstractIterableGetMapDecorator +public class TransformedSplitMap extends AbstractIterableGetMapDecorator implements Put, Serializable { /** Serialization version */ @@ -87,10 +87,10 @@ public class TransformedMap extends AbstractIterableGetMapDecorator< * @return a new transformed map * @throws IllegalArgumentException if map is null */ - public static TransformedMap transformingMap(final Map map, + public static TransformedSplitMap transformingMap(final Map map, final Transformer keyTransformer, final Transformer valueTransformer) { - return new TransformedMap(map, keyTransformer, valueTransformer); + return new TransformedSplitMap(map, keyTransformer, valueTransformer); } //----------------------------------------------------------------------- @@ -107,7 +107,7 @@ public class TransformedMap extends AbstractIterableGetMapDecorator< * means no conversion * @throws IllegalArgumentException if map is null */ - protected TransformedMap(final Map map, final Transformer keyTransformer, + protected TransformedSplitMap(final Map map, final Transformer keyTransformer, final Transformer valueTransformer) { super(map); if (keyTransformer == null) { diff --git a/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java b/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java index 8e02e5b08..15c5f126b 100644 --- a/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java @@ -27,10 +27,10 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.functors.NOPTransformer; import org.apache.commons.collections4.map.HashedMap; -import org.apache.commons.collections4.splitmap.TransformedMap; +import org.apache.commons.collections4.splitmap.TransformedSplitMap; /** - * Tests for {@link TransformedMap} + * Tests for {@link TransformedSplitMap} * * @since 4.0 * @version $Id$ @@ -38,7 +38,7 @@ import org.apache.commons.collections4.splitmap.TransformedMap; @SuppressWarnings("boxing") public class SplitMapUtilsTest extends BulkTest { private Map backingMap; - private TransformedMap transformedMap; + private TransformedSplitMap transformedMap; private final Transformer stringToInt = new Transformer() { public Integer transform(final String input) { @@ -54,7 +54,7 @@ public class SplitMapUtilsTest extends BulkTest { protected void setUp() throws Exception { super.setUp(); backingMap = new HashMap(); - transformedMap = TransformedMap.transformingMap(backingMap, NOPTransformer. nopTransformer(), + transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer. nopTransformer(), stringToInt); for (int i = 0; i < 10; i++) { transformedMap.put(String.valueOf(i), String.valueOf(i)); diff --git a/src/test/java/org/apache/commons/collections4/splitmap/TransformedMapTest.java b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java similarity index 77% rename from src/test/java/org/apache/commons/collections4/splitmap/TransformedMapTest.java rename to src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java index c201e7339..6605e7916 100644 --- a/src/test/java/org/apache/commons/collections4/splitmap/TransformedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java @@ -26,17 +26,13 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.functors.NOPTransformer; /** - * Tests for {@link TransformedMap} - * - * TODO fix version, add Serialization tests - * FIXME the serialization result is stored as TransformedSplitMap.versionX.obj - * to distinguish it from the one for o.a.c.c.map.TransformedMap. + * Tests for {@link TransformedSplitMap} * * @since 4.0 * @version $Id$ */ @SuppressWarnings("boxing") -public class TransformedMapTest extends BulkTest { +public class TransformedSplitMapTest extends BulkTest { private final Transformer intToString = new Transformer() { public String transform(final Integer input) { @@ -56,13 +52,13 @@ public class TransformedMapTest extends BulkTest { } }; - public TransformedMapTest(final String testName) { + public TransformedSplitMapTest(final String testName) { super(testName); } // ----------------------------------------------------------------------- public void testTransformedMap() { - final TransformedMap> map = TransformedMap.transformingMap( + final TransformedSplitMap> map = TransformedSplitMap.transformingMap( new HashMap>(), intToString, objectToClass); final Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 }; @@ -86,7 +82,7 @@ public class TransformedMapTest extends BulkTest { assertEquals(objectToClass.transform(v[0]), map.remove(intToString.transform(k[0]))); assertEquals(--sz, map.size()); - final TransformedMap map2 = TransformedMap.transformingMap( + final TransformedSplitMap map2 = TransformedSplitMap.transformingMap( new HashMap(), NOPTransformer. nopTransformer(), stringToInt); assertEquals(0, map2.size()); for (int i = 0; i < 6; i++) { @@ -106,8 +102,9 @@ public class TransformedMapTest extends BulkTest { // ----------------------------------------------------------------------- public void testMapIterator() { - final TransformedMap map = TransformedMap.transformingMap( - new HashMap(), NOPTransformer. nopTransformer(), stringToInt); + final TransformedSplitMap map = + TransformedSplitMap.transformingMap(new HashMap(), + NOPTransformer. nopTransformer(), stringToInt); assertEquals(0, map.size()); for (int i = 0; i < 6; i++) { map.put(String.valueOf(i), String.valueOf(i)); @@ -121,22 +118,23 @@ public class TransformedMapTest extends BulkTest { } public void testEmptyMap() throws IOException, ClassNotFoundException { - final TransformedMap map = TransformedMap.transformingMap( - new HashMap(), - NOPTransformer.nopTransformer(), - NOPTransformer.nopTransformer() ); + final TransformedSplitMap map = + TransformedSplitMap.transformingMap(new HashMap(), + NOPTransformer.nopTransformer(), + NOPTransformer.nopTransformer() ); - final ObjectInputStream in = new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"/TransformedSplitMap.emptyCollection.version4.obj" ) ); + final ObjectInputStream in = + new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"/TransformedSplitMap.emptyCollection.version4.obj" ) ); final Object readObject = in.readObject(); in.close(); - final TransformedMap readMap = (TransformedMap) readObject; + final TransformedSplitMap readMap = (TransformedSplitMap) readObject; assertTrue( "Map should be empty", readMap.size() == 0 ); assertEquals( map.entrySet(), readMap.entrySet() ); } public void testFullMap() throws IOException, ClassNotFoundException { - final TransformedMap map = TransformedMap.transformingMap( + final TransformedSplitMap map = TransformedSplitMap.transformingMap( new HashMap(), NOPTransformer.nopTransformer(), NOPTransformer.nopTransformer() ); @@ -145,17 +143,18 @@ public class TransformedMapTest extends BulkTest { map.put( "e", "f" ); map.put( "g", "h" ); - final ObjectInputStream in = new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"TransformedSplitMap.fullCollection.version4.obj" ) ); + final ObjectInputStream in = + new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"TransformedSplitMap.fullCollection.version4.obj" ) ); final Object readObject = in.readObject(); in.close(); - final TransformedMap readMap = (TransformedMap) readObject; + final TransformedSplitMap readMap = (TransformedSplitMap) readObject; assertFalse( "Map should not be empty", readMap.size() == 0 ); assertEquals( map.entrySet(), readMap.entrySet() ); } // public void testCreate() throws IOException { -// TransformedMap map = TransformedMap.transformingMap( +// TransformedSplitMap map = TransformedSplitMap.transformingMap( // new HashMap(), // NOPTransformer.nopTransformer(), // NOPTransformer.nopTransformer() ); diff --git a/src/test/resources/data/test/TransformedSplitMap.emptyCollection.version4.obj b/src/test/resources/data/test/TransformedSplitMap.emptyCollection.version4.obj index f0cc10c72..5ef8e3486 100644 Binary files a/src/test/resources/data/test/TransformedSplitMap.emptyCollection.version4.obj and b/src/test/resources/data/test/TransformedSplitMap.emptyCollection.version4.obj differ diff --git a/src/test/resources/data/test/TransformedSplitMap.fullCollection.version4.obj b/src/test/resources/data/test/TransformedSplitMap.fullCollection.version4.obj index cea50c79e..3d84f94f9 100644 Binary files a/src/test/resources/data/test/TransformedSplitMap.fullCollection.version4.obj and b/src/test/resources/data/test/TransformedSplitMap.fullCollection.version4.obj differ