From 88cbfb72368285f1f10d949bf45e5f9c5dd032fb Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sat, 4 Nov 2006 11:33:22 +0000 Subject: [PATCH] Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/branches/collections_jdk5_branch@471166 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE-NOTES.txt | 3 + .../apache/commons/collections/BagUtils.java | 28 ---- .../commons/collections/BufferUtils.java | 17 +-- .../commons/collections/CollectionUtils.java | 14 -- .../apache/commons/collections/ListUtils.java | 14 -- .../apache/commons/collections/MapUtils.java | 31 ----- .../apache/commons/collections/SetUtils.java | 28 ---- .../commons/collections/bag/TypedBag.java | 61 --------- .../collections/bag/TypedSortedBag.java | 61 --------- .../collections/buffer/TypedBuffer.java | 61 --------- .../collection/TypedCollection.java | 61 --------- .../commons/collections/list/TypedList.java | 60 --------- .../commons/collections/map/TypedMap.java | 73 ----------- .../collections/map/TypedSortedMap.java | 73 ----------- .../commons/collections/set/TypedSet.java | 60 --------- .../collections/set/TypedSortedSet.java | 60 --------- .../commons/collections/TestBagUtils.java | 36 ----- .../collections/TestCollectionUtils.java | 38 ------ .../commons/collections/TestMapUtils.java | 63 --------- .../commons/collections/bag/TestAll.java | 2 - .../commons/collections/bag/TestTypedBag.java | 124 ------------------ .../collections/bag/TestTypedSortedBag.java | 102 -------------- .../commons/collections/list/TestAll.java | 1 - .../collections/list/TestTypedList.java | 66 ---------- .../commons/collections/set/TestAll.java | 2 - .../commons/collections/set/TestTypedSet.java | 63 --------- .../collections/set/TestTypedSortedSet.java | 110 ---------------- 27 files changed, 4 insertions(+), 1308 deletions(-) delete mode 100644 src/java/org/apache/commons/collections/bag/TypedBag.java delete mode 100644 src/java/org/apache/commons/collections/bag/TypedSortedBag.java delete mode 100644 src/java/org/apache/commons/collections/buffer/TypedBuffer.java delete mode 100644 src/java/org/apache/commons/collections/collection/TypedCollection.java delete mode 100644 src/java/org/apache/commons/collections/list/TypedList.java delete mode 100644 src/java/org/apache/commons/collections/map/TypedMap.java delete mode 100644 src/java/org/apache/commons/collections/map/TypedSortedMap.java delete mode 100644 src/java/org/apache/commons/collections/set/TypedSet.java delete mode 100644 src/java/org/apache/commons/collections/set/TypedSortedSet.java delete mode 100644 src/test/org/apache/commons/collections/bag/TestTypedBag.java delete mode 100644 src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java delete mode 100644 src/test/org/apache/commons/collections/list/TestTypedList.java delete mode 100644 src/test/org/apache/commons/collections/set/TestTypedSet.java delete mode 100644 src/test/org/apache/commons/collections/set/TestTypedSortedSet.java diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 816f173e9..2e73a3886 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -35,6 +35,9 @@ Changes from commons-collections - Removed FastTreeSet - no direct replacement - use ConcurrentHashMap or synchronized TreeMap +- Removed Typed* containers such as TypedList and TypedMap + - use generics for type safety, or Collections.checked*() + Feedback -------- diff --git a/src/java/org/apache/commons/collections/BagUtils.java b/src/java/org/apache/commons/collections/BagUtils.java index e0c0cb386..ff8202277 100644 --- a/src/java/org/apache/commons/collections/BagUtils.java +++ b/src/java/org/apache/commons/collections/BagUtils.java @@ -24,8 +24,6 @@ import org.apache.commons.collections.bag.SynchronizedSortedBag; import org.apache.commons.collections.bag.TransformedBag; import org.apache.commons.collections.bag.TransformedSortedBag; import org.apache.commons.collections.bag.TreeBag; -import org.apache.commons.collections.bag.TypedBag; -import org.apache.commons.collections.bag.TypedSortedBag; import org.apache.commons.collections.bag.UnmodifiableBag; import org.apache.commons.collections.bag.UnmodifiableSortedBag; @@ -121,19 +119,6 @@ public class BagUtils { return PredicatedBag.decorate(bag, predicate); } - /** - * Returns a typed bag backed by the given bag. - *

- * Only objects of the specified type can be added to the bag. - * - * @param bag the bag to limit to a specific type, must not be null - * @param type the type of objects which may be added to the bag - * @return a typed bag backed by the specified bag - */ - public static Bag typedBag(Bag bag, Class type) { - return TypedBag.decorate(bag, type); - } - /** * Returns a transformed bag backed by the given bag. *

@@ -212,19 +197,6 @@ public class BagUtils { return PredicatedSortedBag.decorate(bag, predicate); } - /** - * Returns a typed sorted bag backed by the given bag. - *

- * Only objects of the specified type can be added to the bag. - * - * @param bag the bag to limit to a specific type, must not be null - * @param type the type of objects which may be added to the bag - * @return a typed bag backed by the specified bag - */ - public static SortedBag typedSortedBag(SortedBag bag, Class type) { - return TypedSortedBag.decorate(bag, type); - } - /** * Returns a transformed sorted bag backed by the given bag. *

diff --git a/src/java/org/apache/commons/collections/BufferUtils.java b/src/java/org/apache/commons/collections/BufferUtils.java index 2a8d4c2e2..625743458 100644 --- a/src/java/org/apache/commons/collections/BufferUtils.java +++ b/src/java/org/apache/commons/collections/BufferUtils.java @@ -17,12 +17,11 @@ package org.apache.commons.collections; import org.apache.commons.collections.buffer.BlockingBuffer; +import org.apache.commons.collections.buffer.BoundedBuffer; import org.apache.commons.collections.buffer.PredicatedBuffer; import org.apache.commons.collections.buffer.SynchronizedBuffer; import org.apache.commons.collections.buffer.TransformedBuffer; -import org.apache.commons.collections.buffer.TypedBuffer; import org.apache.commons.collections.buffer.UnmodifiableBuffer; -import org.apache.commons.collections.buffer.BoundedBuffer; /** * Provides utility methods and decorators for {@link Buffer} instances. @@ -168,20 +167,6 @@ public class BufferUtils { return PredicatedBuffer.decorate(buffer, predicate); } - /** - * Returns a typed buffer backed by the given buffer. - *

- * Only elements of the specified type can be added to the buffer. - * - * @param buffer the buffer to predicate, must not be null - * @param type the type to allow into the buffer, must not be null - * @return a typed buffer - * @throws IllegalArgumentException if the buffer or type is null - */ - public static Buffer typedBuffer(Buffer buffer, Class type) { - return TypedBuffer.decorate(buffer, type); - } - /** * Returns a transformed buffer backed by the given buffer. *

diff --git a/src/java/org/apache/commons/collections/CollectionUtils.java b/src/java/org/apache/commons/collections/CollectionUtils.java index 04acb6e60..6818d262d 100644 --- a/src/java/org/apache/commons/collections/CollectionUtils.java +++ b/src/java/org/apache/commons/collections/CollectionUtils.java @@ -31,7 +31,6 @@ import java.util.Set; import org.apache.commons.collections.collection.PredicatedCollection; import org.apache.commons.collections.collection.SynchronizedCollection; import org.apache.commons.collections.collection.TransformedCollection; -import org.apache.commons.collections.collection.TypedCollection; import org.apache.commons.collections.collection.UnmodifiableBoundedCollection; import org.apache.commons.collections.collection.UnmodifiableCollection; @@ -1072,19 +1071,6 @@ public class CollectionUtils { return PredicatedCollection.decorate(collection, predicate); } - /** - * Returns a typed collection backed by the given collection. - *

- * Only objects of the specified type can be added to the collection. - * - * @param collection the collection to limit to a specific type, must not be null - * @param type the type of objects which may be added to the collection - * @return a typed collection backed by the specified collection - */ - public static Collection typedCollection(Collection collection, Class type) { - return TypedCollection.decorate(collection, type); - } - /** * Returns a transformed bag backed by the given collection. *

diff --git a/src/java/org/apache/commons/collections/ListUtils.java b/src/java/org/apache/commons/collections/ListUtils.java index 532b4a391..218488f2b 100644 --- a/src/java/org/apache/commons/collections/ListUtils.java +++ b/src/java/org/apache/commons/collections/ListUtils.java @@ -27,7 +27,6 @@ import org.apache.commons.collections.list.LazyList; import org.apache.commons.collections.list.PredicatedList; import org.apache.commons.collections.list.SynchronizedList; import org.apache.commons.collections.list.TransformedList; -import org.apache.commons.collections.list.TypedList; import org.apache.commons.collections.list.UnmodifiableList; /** @@ -331,19 +330,6 @@ public class ListUtils { return PredicatedList.decorate(list, predicate); } - /** - * Returns a typed list backed by the given list. - *

- * Only objects of the specified type can be added to the list. - * - * @param list the list to limit to a specific type, must not be null - * @param type the type of objects which may be added to the list - * @return a typed list backed by the specified list - */ - public static List typedList(List list, Class type) { - return TypedList.decorate(list, type); - } - /** * Returns a transformed list backed by the given list. *

diff --git a/src/java/org/apache/commons/collections/MapUtils.java b/src/java/org/apache/commons/collections/MapUtils.java index b2e14b18d..6ea943460 100644 --- a/src/java/org/apache/commons/collections/MapUtils.java +++ b/src/java/org/apache/commons/collections/MapUtils.java @@ -39,8 +39,6 @@ import org.apache.commons.collections.map.PredicatedMap; import org.apache.commons.collections.map.PredicatedSortedMap; import org.apache.commons.collections.map.TransformedMap; import org.apache.commons.collections.map.TransformedSortedMap; -import org.apache.commons.collections.map.TypedMap; -import org.apache.commons.collections.map.TypedSortedMap; import org.apache.commons.collections.map.UnmodifiableMap; import org.apache.commons.collections.map.UnmodifiableSortedMap; @@ -1273,21 +1271,6 @@ public class MapUtils { return PredicatedMap.decorate(map, keyPred, valuePred); } - /** - * Returns a typed map backed by the given map. - *

- * Only keys and values of the specified types can be added to the map. - * - * @param map the map to limit to a specific type, must not be null - * @param keyType the type of keys which may be added to the map, must not be null - * @param valueType the type of values which may be added to the map, must not be null - * @return a typed map backed by the specified map - * @throws IllegalArgumentException if the Map or Class is null - */ - public static Map typedMap(Map map, Class keyType, Class valueType) { - return TypedMap.decorate(map, keyType, valueType); - } - /** * Returns a transformed map backed by the given map. *

@@ -1517,20 +1500,6 @@ public class MapUtils { return PredicatedSortedMap.decorate(map, keyPred, valuePred); } - /** - * Returns a typed sorted map backed by the given map. - *

- * Only keys and values of the specified types can be added to the map. - * - * @param map the map to limit to a specific type, must not be null - * @param keyType the type of keys which may be added to the map, must not be null - * @param valueType the type of values which may be added to the map, must not be null - * @return a typed map backed by the specified map - */ - public static SortedMap typedSortedMap(SortedMap map, Class keyType, Class valueType) { - return TypedSortedMap.decorate(map, keyType, valueType); - } - /** * Returns a transformed sorted map backed by the given map. *

diff --git a/src/java/org/apache/commons/collections/SetUtils.java b/src/java/org/apache/commons/collections/SetUtils.java index 76f669f0f..f84b8436f 100644 --- a/src/java/org/apache/commons/collections/SetUtils.java +++ b/src/java/org/apache/commons/collections/SetUtils.java @@ -30,8 +30,6 @@ import org.apache.commons.collections.set.SynchronizedSet; import org.apache.commons.collections.set.SynchronizedSortedSet; import org.apache.commons.collections.set.TransformedSet; import org.apache.commons.collections.set.TransformedSortedSet; -import org.apache.commons.collections.set.TypedSet; -import org.apache.commons.collections.set.TypedSortedSet; import org.apache.commons.collections.set.UnmodifiableSet; import org.apache.commons.collections.set.UnmodifiableSortedSet; @@ -193,19 +191,6 @@ public class SetUtils { return PredicatedSet.decorate(set, predicate); } - /** - * Returns a typed set backed by the given set. - *

- * Only objects of the specified type can be added to the set. - * - * @param set the set to limit to a specific type, must not be null - * @param type the type of objects which may be added to the set - * @return a typed set backed by the specified set - */ - public static Set typedSet(Set set, Class type) { - return TypedSet.decorate(set, type); - } - /** * Returns a transformed set backed by the given set. *

@@ -294,19 +279,6 @@ public class SetUtils { return PredicatedSortedSet.decorate(set, predicate); } - /** - * Returns a typed sorted set backed by the given set. - *

- * Only objects of the specified type can be added to the set. - * - * @param set the set to limit to a specific type, must not be null - * @param type the type of objects which may be added to the set - * @return a typed set backed by the specified set - */ - public static SortedSet typedSortedSet(SortedSet set, Class type) { - return TypedSortedSet.decorate(set, type); - } - /** * Returns a transformed sorted set backed by the given set. *

diff --git a/src/java/org/apache/commons/collections/bag/TypedBag.java b/src/java/org/apache/commons/collections/bag/TypedBag.java deleted file mode 100644 index d05985a3a..000000000 --- a/src/java/org/apache/commons/collections/bag/TypedBag.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.bag; - -import org.apache.commons.collections.Bag; -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another Bag to validate that elements added - * are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedBag { - - /** - * Factory method to create a typed bag. - *

- * If there are any elements already in the bag being decorated, they - * are validated. - * - * @param bag the bag to decorate, must not be null - * @param type the type to allow into the bag, must not be null - * @return a new typed Bag - * @throws IllegalArgumentException if bag or type is null - * @throws IllegalArgumentException if the bag contains invalid elements - */ - public static Bag decorate(Bag bag, Class type) { - return new PredicatedBag(bag, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedBag() { - super(); - } - -} diff --git a/src/java/org/apache/commons/collections/bag/TypedSortedBag.java b/src/java/org/apache/commons/collections/bag/TypedSortedBag.java deleted file mode 100644 index bdd063d45..000000000 --- a/src/java/org/apache/commons/collections/bag/TypedSortedBag.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.bag; - -import org.apache.commons.collections.SortedBag; -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another SortedBag to validate that elements added - * are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedSortedBag { - - /** - * Factory method to create a typed sorted bag. - *

- * If there are any elements already in the bag being decorated, they - * are validated. - * - * @param bag the bag to decorate, must not be null - * @param type the type to allow into the bag, must not be null - * @return a new transformed SortedBag - * @throws IllegalArgumentException if bag or type is null - * @throws IllegalArgumentException if the bag contains invalid elements - */ - public static SortedBag decorate(SortedBag bag, Class type) { - return new PredicatedSortedBag(bag, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedSortedBag() { - super(); - } - -} diff --git a/src/java/org/apache/commons/collections/buffer/TypedBuffer.java b/src/java/org/apache/commons/collections/buffer/TypedBuffer.java deleted file mode 100644 index 3758008d7..000000000 --- a/src/java/org/apache/commons/collections/buffer/TypedBuffer.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.buffer; - -import org.apache.commons.collections.Buffer; -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another Buffer to validate that elements added - * are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedBuffer { - - /** - * Factory method to create a typed list. - *

- * If there are any elements already in the buffer being decorated, they - * are validated. - * - * @param buffer the buffer to decorate, must not be null - * @param type the type to allow into the buffer, must not be null - * @return a new typed Buffer - * @throws IllegalArgumentException if buffer or type is null - * @throws IllegalArgumentException if the buffer contains invalid elements - */ - public static Buffer decorate(Buffer buffer, Class type) { - return new PredicatedBuffer(buffer, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedBuffer() { - super(); - } - -} diff --git a/src/java/org/apache/commons/collections/collection/TypedCollection.java b/src/java/org/apache/commons/collections/collection/TypedCollection.java deleted file mode 100644 index 241d42542..000000000 --- a/src/java/org/apache/commons/collections/collection/TypedCollection.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.collection; - -import java.util.Collection; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates a Collection to validate that elements added are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedCollection { - - /** - * Factory method to create a typed collection. - *

- * If there are any elements already in the collection being decorated, they - * are validated. - * - * @param coll the collection to decorate, must not be null - * @param type the type to allow into the collection, must not be null - * @return a new typed collection - * @throws IllegalArgumentException if collection or type is null - * @throws IllegalArgumentException if the collection contains invalid elements - */ - public static Collection decorate(Collection coll, Class type) { - return new PredicatedCollection(coll, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedCollection() { - super(); - } - -} diff --git a/src/java/org/apache/commons/collections/list/TypedList.java b/src/java/org/apache/commons/collections/list/TypedList.java deleted file mode 100644 index 8c6b8141c..000000000 --- a/src/java/org/apache/commons/collections/list/TypedList.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.list; - -import java.util.List; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another List to validate that elements - * added are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedList { - - /** - * Factory method to create a typed list. - *

- * If there are any elements already in the list being decorated, they - * are validated. - * - * @param list the list to decorate, must not be null - * @param type the type to allow into the collection, must not be null - * @throws IllegalArgumentException if list or type is null - * @throws IllegalArgumentException if the list contains invalid elements - */ - public static List decorate(List list, Class type) { - return new PredicatedList(list, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedList() { - } - -} diff --git a/src/java/org/apache/commons/collections/map/TypedMap.java b/src/java/org/apache/commons/collections/map/TypedMap.java deleted file mode 100644 index 519b3d768..000000000 --- a/src/java/org/apache/commons/collections/map/TypedMap.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.map; - -import java.util.Map; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another Map to validate that elements added - * are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - *

- * Note that TypedMap is not synchronized and is not thread-safe. - * If you wish to use this map from multiple threads concurrently, you must use - * appropriate synchronization. The simplest approach is to wrap this map - * using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw - * exceptions when accessed by concurrent threads without synchronization. - *

- * The returned implementation is Serializable from Commons Collections 3.1. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedMap { - - /** - * Factory method to create a typed map. - *

- * If there are any elements already in the map being decorated, they - * are validated. - * - * @param map the map to decorate, must not be null - * @param keyType the type to allow as keys, must not be null - * @param valueType the type to allow as values, must not be null - * @throws IllegalArgumentException if list or type is null - * @throws IllegalArgumentException if the list contains invalid elements - */ - public static Map decorate(Map map, Class keyType, Class valueType) { - return new PredicatedMap( - map, - InstanceofPredicate.getInstance(keyType), - InstanceofPredicate.getInstance(valueType) - ); - } - - /** - * Restrictive constructor. - */ - protected TypedMap() { - } - -} diff --git a/src/java/org/apache/commons/collections/map/TypedSortedMap.java b/src/java/org/apache/commons/collections/map/TypedSortedMap.java deleted file mode 100644 index bcc1501f4..000000000 --- a/src/java/org/apache/commons/collections/map/TypedSortedMap.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.map; - -import java.util.SortedMap; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another SortedMap to validate that elements added - * are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - *

- * Note that TypedSortedMap is not synchronized and is not thread-safe. - * If you wish to use this map from multiple threads concurrently, you must use - * appropriate synchronization. The simplest approach is to wrap this map - * using {@link java.util.Collections#synchronizedSortedMap}. This class may throw - * exceptions when accessed by concurrent threads without synchronization. - *

- * The returned implementation is Serializable from Commons Collections 3.1. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedSortedMap { - - /** - * Factory method to create a typed sorted map. - *

- * If there are any elements already in the map being decorated, they - * are validated. - * - * @param map the map to decorate, must not be null - * @param keyType the type to allow as keys, must not be null - * @param valueType the type to allow as values, must not be null - * @throws IllegalArgumentException if list or type is null - * @throws IllegalArgumentException if the list contains invalid elements - */ - public static SortedMap decorate(SortedMap map, Class keyType, Class valueType) { - return new PredicatedSortedMap( - map, - InstanceofPredicate.getInstance(keyType), - InstanceofPredicate.getInstance(valueType) - ); - } - - /** - * Restrictive constructor. - */ - protected TypedSortedMap() { - } - -} diff --git a/src/java/org/apache/commons/collections/set/TypedSet.java b/src/java/org/apache/commons/collections/set/TypedSet.java deleted file mode 100644 index 168783d1b..000000000 --- a/src/java/org/apache/commons/collections/set/TypedSet.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.set; - -import java.util.Set; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another Set to validate that elements - * added are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedSet { - - /** - * Factory method to create a typed set. - *

- * If there are any elements already in the set being decorated, they - * are validated. - * - * @param set the set to decorate, must not be null - * @param type the type to allow into the collection, must not be null - * @throws IllegalArgumentException if set or type is null - * @throws IllegalArgumentException if the set contains invalid elements - */ - public static Set decorate(Set set, Class type) { - return new PredicatedSet(set, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedSet() { - } - -} diff --git a/src/java/org/apache/commons/collections/set/TypedSortedSet.java b/src/java/org/apache/commons/collections/set/TypedSortedSet.java deleted file mode 100644 index a0d7c70ae..000000000 --- a/src/java/org/apache/commons/collections/set/TypedSortedSet.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.set; - -import java.util.SortedSet; - -import org.apache.commons.collections.functors.InstanceofPredicate; - -/** - * Decorates another SortedSet to validate that elements - * added are of a specific type. - *

- * The validation of additions is performed via an instanceof test against - * a specified Class. If an object cannot be added to the - * collection, an IllegalArgumentException is thrown. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Matthew Hawthorne - */ -public class TypedSortedSet { - - /** - * Factory method to create a typed sorted set. - *

- * If there are any elements already in the set being decorated, they - * are validated. - * - * @param set the set to decorate, must not be null - * @param type the type to allow into the collection, must not be null - * @throws IllegalArgumentException if set or type is null - * @throws IllegalArgumentException if the set contains invalid elements - */ - public static SortedSet decorate(SortedSet set, Class type) { - return new PredicatedSortedSet(set, InstanceofPredicate.getInstance(type)); - } - - /** - * Restrictive constructor. - */ - protected TypedSortedSet() { - } - -} diff --git a/src/test/org/apache/commons/collections/TestBagUtils.java b/src/test/org/apache/commons/collections/TestBagUtils.java index 9144d843f..54600a4f2 100644 --- a/src/test/org/apache/commons/collections/TestBagUtils.java +++ b/src/test/org/apache/commons/collections/TestBagUtils.java @@ -97,24 +97,6 @@ public class TestBagUtils extends BulkTest { } } - public void testTypedBag() { - Bag bag = BagUtils.typedBag(new HashBag(), stringClass); - assertTrue("Returned object should be a TypedBag.", - bag instanceof PredicatedBag); - try { - bag = BagUtils.typedBag(null, stringClass); - fail("Expecting IllegalArgumentException for null bag."); - } catch (IllegalArgumentException ex) { - // expected - } - try { - bag = BagUtils.typedBag(new HashBag(), null); - fail("Expecting IllegalArgumentException for null type."); - } catch (IllegalArgumentException ex) { - // expected - } - } - public void testTransformedBag() { Bag bag = BagUtils.transformedBag(new HashBag(), nopTransformer); assertTrue("Returned object should be an TransformedBag.", @@ -175,24 +157,6 @@ public class TestBagUtils extends BulkTest { } } - public void testTypedSortedBag() { - Bag bag = BagUtils.typedSortedBag(new TreeBag(), stringClass); - assertTrue("Returned object should be a TypedSortedBag.", - bag instanceof PredicatedSortedBag); - try { - bag = BagUtils.typedSortedBag(null, stringClass); - fail("Expecting IllegalArgumentException for null bag."); - } catch (IllegalArgumentException ex) { - // expected - } - try { - bag = BagUtils.typedSortedBag(new TreeBag(), null); - fail("Expecting IllegalArgumentException for null type."); - } catch (IllegalArgumentException ex) { - // expected - } - } - public void testTransformedSortedBag() { Bag bag = BagUtils.transformedSortedBag(new TreeBag(), nopTransformer); assertTrue("Returned object should be an TransformedSortedBag", diff --git a/src/test/org/apache/commons/collections/TestCollectionUtils.java b/src/test/org/apache/commons/collections/TestCollectionUtils.java index d0e1b2a2c..fbc59dc39 100644 --- a/src/test/org/apache/commons/collections/TestCollectionUtils.java +++ b/src/test/org/apache/commons/collections/TestCollectionUtils.java @@ -36,7 +36,6 @@ import junit.framework.TestSuite; import org.apache.commons.collections.bag.HashBag; import org.apache.commons.collections.buffer.BoundedFifoBuffer; -import org.apache.commons.collections.collection.AbstractTestCollection; import org.apache.commons.collections.collection.PredicatedCollection; import org.apache.commons.collections.collection.SynchronizedCollection; import org.apache.commons.collections.collection.TransformedCollection; @@ -998,43 +997,6 @@ public class TestCollectionUtils extends TestCase { - public BulkTest bulkTestTypedCollection() { - return new TestTypedCollection("") { - public Collection typedCollection() { - return CollectionUtils.typedCollection( - new ArrayList(), - super.getType()); - } - - public BulkTest bulkTestAll() { - return new AbstractTestCollection("") { - public Collection makeCollection() { - return typedCollection(); - } - - public Collection makeConfirmedCollection() { - return new ArrayList(); - } - - public Collection makeConfirmedFullCollection() { - ArrayList list = new ArrayList(); - list.addAll(java.util.Arrays.asList(getFullElements())); - return list; - } - - public Object[] getFullElements() { - return getFullNonNullStringElements(); - } - - public Object[] getOtherElements() { - return getOtherNonNullStringElements(); - } - - }; - } - }; - } - public void testIsFull() { Set set = new HashSet(); set.add("1"); diff --git a/src/test/org/apache/commons/collections/TestMapUtils.java b/src/test/org/apache/commons/collections/TestMapUtils.java index 0c7745921..e1243d7d7 100644 --- a/src/test/org/apache/commons/collections/TestMapUtils.java +++ b/src/test/org/apache/commons/collections/TestMapUtils.java @@ -33,7 +33,6 @@ import org.apache.commons.collections.keyvalue.DefaultKeyValue; import org.apache.commons.collections.keyvalue.DefaultMapEntry; import org.apache.commons.collections.map.LazyMap; import org.apache.commons.collections.map.PredicatedMap; -import org.apache.commons.collections.map.TestPredicatedMap; /** * Tests for MapUtils. @@ -78,68 +77,6 @@ public class TestMapUtils extends BulkTest { } } - // Since a typed map is a predicated map, I copied the tests for predicated map - public void testTypedMapIllegalPut() { - final Map map = MapUtils.typedMap(new HashMap(), String.class, String.class); - - try { - map.put("Hi", new Integer(3)); - fail("Illegal value should raise IllegalArgument"); - } catch (IllegalArgumentException e) { - // expected - } - - try { - map.put(new Integer(3), "Hi"); - fail("Illegal key should raise IllegalArgument"); - } catch (IllegalArgumentException e) { - // expected - } - - assertTrue(!map.containsKey(new Integer(3))); - assertTrue(!map.containsValue(new Integer(3))); - - Map map2 = new HashMap(); - map2.put("A", "a"); - map2.put("B", "b"); - map2.put("C", "c"); - map2.put("c", new Integer(3)); - - try { - map.putAll(map2); - fail("Illegal value should raise IllegalArgument"); - } catch (IllegalArgumentException e) { - // expected - } - - map.put("E", "e"); - Iterator iterator = map.entrySet().iterator(); - try { - Map.Entry entry = (Map.Entry)iterator.next(); - entry.setValue(new Integer(3)); - fail("Illegal value should raise IllegalArgument"); - } catch (IllegalArgumentException e) { - // expected - } - - } - - public BulkTest bulkTestTypedMap() { - return new TestPredicatedMap("") { - public boolean isAllowNullKey() { - return false; - } - - public boolean isAllowNullValue() { - return false; - } - - public Map makeEmptyMap() { - return MapUtils.typedMap(new HashMap(), String.class, String.class); - } - }; - } - public void testLazyMapFactory() { Factory factory = FactoryUtils.constantFactory(new Integer(5)); Map map = MapUtils.lazyMap(new HashMap(), factory); diff --git a/src/test/org/apache/commons/collections/bag/TestAll.java b/src/test/org/apache/commons/collections/bag/TestAll.java index 3adb32f2f..21b60400c 100644 --- a/src/test/org/apache/commons/collections/bag/TestAll.java +++ b/src/test/org/apache/commons/collections/bag/TestAll.java @@ -48,8 +48,6 @@ public class TestAll extends TestCase { suite.addTest(TestTransformedBag.suite()); suite.addTest(TestTransformedSortedBag.suite()); suite.addTest(TestTreeBag.suite()); - suite.addTest(TestTypedBag.suite()); - suite.addTest(TestTypedSortedBag.suite()); return suite; } diff --git a/src/test/org/apache/commons/collections/bag/TestTypedBag.java b/src/test/org/apache/commons/collections/bag/TestTypedBag.java deleted file mode 100644 index 3fc778e07..000000000 --- a/src/test/org/apache/commons/collections/bag/TestTypedBag.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.bag; - -import java.util.Set; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.commons.collections.Bag; - -/** - * Extension of {@link TestBag} for exercising the {@link TypedBag} - * implementation. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Phil Steitz - */ -public class TestTypedBag extends AbstractTestBag { - - public TestTypedBag(String testName) { - super(testName); - } - - public static Test suite() { - return new TestSuite(TestTypedBag.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTypedBag.class.getName()}; - junit.textui.TestRunner.main(testCaseName); - } - - //-------------------------------------------------------------------------- - - protected Class stringClass = this.getName().getClass(); - private Object obj = new Object(); - protected Class objectClass = obj.getClass(); - - protected Bag decorateBag(HashBag bag, Class claz) { - return TypedBag.decorate(bag, claz); - } - - public Bag makeBag() { - return decorateBag(new HashBag(), objectClass); - } - - protected Bag makeTestBag() { - return decorateBag(new HashBag(), stringClass); - } - - //-------------------------------------------------------------------------- - - public void testlegalAddRemove() { - Bag bag = makeTestBag(); - assertEquals(0, bag.size()); - Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "1"}; - for (int i = 0; i < els.length; i++) { - bag.add(els[i]); - assertEquals(i + 1, bag.size()); - assertEquals(true, bag.contains(els[i])); - } - Set set = ((PredicatedBag) bag).uniqueSet(); - assertTrue("Unique set contains the first element",set.contains(els[0])); - assertEquals(true, bag.remove(els[0])); - set = ((PredicatedBag) bag).uniqueSet(); - assertTrue("Unique set now does not contain the first element", - !set.contains(els[0])); - } - - public void testIllegalAdd() { - Bag bag = makeTestBag(); - Integer i = new Integer(3); - try { - bag.add(i); - fail("Integer should fail type check."); - } catch (IllegalArgumentException e) { - // expected - } - assertTrue("Collection shouldn't contain illegal element", - !bag.contains(i)); - } - - public void testIllegalDecorate() { - HashBag elements = new HashBag(); - elements.add("one"); - elements.add("two"); - elements.add(new Integer(3)); - elements.add("four"); - try { - Bag bag = decorateBag(elements, stringClass); - fail("Bag contains an element that should fail the type test."); - } catch (IllegalArgumentException e) { - // expected - } - try { - Bag bag = decorateBag(new HashBag(), null); - fail("Expectiing IllegalArgumentException for null predicate."); - } catch (IllegalArgumentException e) { - // expected - } - } - - protected boolean skipSerializedCanonicalTests() { - return true; - } - -} diff --git a/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java deleted file mode 100644 index 03b1964c8..000000000 --- a/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.bag; - -import java.util.Comparator; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.commons.collections.Bag; -import org.apache.commons.collections.SortedBag; - -/** - * Extension of {@link TestBag} for exercising the {@link TypedSortedBag} - * implementation. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Phil Steitz - */ -public class TestTypedSortedBag extends AbstractTestSortedBag { - - public TestTypedSortedBag(String testName) { - super(testName); - } - - public static Test suite() { - return new TestSuite(TestTypedSortedBag.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTypedSortedBag.class.getName()}; - junit.textui.TestRunner.main(testCaseName); - } - - //-------------------------------------------------------------------------- - - protected Class stringClass = this.getName().getClass(); - private Object obj = new Object(); - protected Class objectClass = obj.getClass(); - protected SortedBag nullBag = null; - - protected SortedBag decorateBag(SortedBag bag, Class claz) { - return TypedSortedBag.decorate(bag, claz); - } - - public Bag makeBag() { - return decorateBag(new TreeBag(), objectClass); - } - - protected Bag makeTestBag() { - return decorateBag(new TreeBag(), stringClass); - } - - //-------------------------------------------------------------------------- - - public void testDecorate() { - SortedBag bag = decorateBag(new TreeBag(), stringClass); - try { - SortedBag bag3 = decorateBag(new TreeBag(), null); - fail("Expecting IllegalArgumentException for null predicate"); - } catch (IllegalArgumentException e) {} - try { - SortedBag bag4 = decorateBag(nullBag, stringClass); - fail("Expecting IllegalArgumentException for null bag"); - } catch (IllegalArgumentException e) {} - } - - public void testSortOrder() { - SortedBag bag = decorateBag(new TreeBag(), stringClass); - String one = "one"; - String two = "two"; - String three = "three"; - bag.add(one); - bag.add(two); - bag.add(three); - assertEquals("first element", bag.first(), one); - assertEquals("last element", bag.last(), two); - Comparator c = bag.comparator(); - assertTrue("natural order, so comparator should be null", c == null); - } - - protected boolean skipSerializedCanonicalTests() { - return true; - } - -} diff --git a/src/test/org/apache/commons/collections/list/TestAll.java b/src/test/org/apache/commons/collections/list/TestAll.java index 4599a8308..562be4243 100644 --- a/src/test/org/apache/commons/collections/list/TestAll.java +++ b/src/test/org/apache/commons/collections/list/TestAll.java @@ -52,7 +52,6 @@ public class TestAll extends TestCase { suite.addTest(TestSetUniqueList.suite()); suite.addTest(TestSynchronizedList.suite()); suite.addTest(TestTransformedList.suite()); - suite.addTest(TestTypedList.suite()); suite.addTest(TestUnmodifiableList.suite()); return suite; diff --git a/src/test/org/apache/commons/collections/list/TestTypedList.java b/src/test/org/apache/commons/collections/list/TestTypedList.java deleted file mode 100644 index cb71c00fb..000000000 --- a/src/test/org/apache/commons/collections/list/TestTypedList.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.list; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Extension of {@link TestList} for exercising the {@link TypedList} - * implementation. - * - * @since Commons Collections 3.1 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - */ -public class TestTypedList extends AbstractTestList { - - public TestTypedList(String testName) { - super(testName); - } - - public static Test suite() { - return new TestSuite(TestTypedList.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTypedList.class.getName()}; - junit.textui.TestRunner.main(testCaseName); - } - - public Collection makeConfirmedCollection() { - return new ArrayList(); - } - - public List makeEmptyList() { - return TypedList.decorate(new ArrayList(), Object.class); - } - - public boolean isNullSupported() { - return false; - } - - public boolean skipSerializedCanonicalTests() { - return true; // TypedList and PredicatedList get confused - } - -} diff --git a/src/test/org/apache/commons/collections/set/TestAll.java b/src/test/org/apache/commons/collections/set/TestAll.java index 4666486d3..2a56131d9 100644 --- a/src/test/org/apache/commons/collections/set/TestAll.java +++ b/src/test/org/apache/commons/collections/set/TestAll.java @@ -53,8 +53,6 @@ public class TestAll extends TestCase { suite.addTest(TestSynchronizedSortedSet.suite()); suite.addTest(TestTransformedSet.suite()); suite.addTest(TestTransformedSortedSet.suite()); - suite.addTest(TestTypedSet.suite()); - suite.addTest(TestTypedSortedSet.suite()); suite.addTest(TestUnmodifiableSet.suite()); suite.addTest(TestUnmodifiableSortedSet.suite()); diff --git a/src/test/org/apache/commons/collections/set/TestTypedSet.java b/src/test/org/apache/commons/collections/set/TestTypedSet.java deleted file mode 100644 index 34ed249d7..000000000 --- a/src/test/org/apache/commons/collections/set/TestTypedSet.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.set; - -import java.util.HashSet; -import java.util.Set; - -import junit.framework.Test; - -import org.apache.commons.collections.BulkTest; - -/** - * Extension of {@link AbstractTestSet} for exercising the - * {@link TypedSet} implementation. - * - * @since Commons Collections 3.1 - * @version $Revision$ $Date$ - * - * @author Phil Steitz - */ -public class TestTypedSet extends AbstractTestSet{ - - public TestTypedSet(String testName) { - super(testName); - } - - public static Test suite() { - return BulkTest.makeSuite(TestTypedSet.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTypedSet.class.getName()}; - junit.textui.TestRunner.main(testCaseName); - } - - //------------------------------------------------------------------- - public Set makeEmptySet() { - return TypedSet.decorate(new HashSet(), Object.class); - } - - public boolean isNullSupported() { - return false; - } - - public boolean skipSerializedCanonicalTests() { - return true; // Typed and Predicated get confused - } - -} diff --git a/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java b/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java deleted file mode 100644 index 1c9c48198..000000000 --- a/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections.set; - -import java.util.Arrays; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import junit.framework.Test; - -import org.apache.commons.collections.BulkTest; - - -/** - * Extension of {@link AbstractTestSortedSet} for exercising the - * {@link TypedSortedSet} implementation. - * - * @since Commons Collections 3.0 - * @version $Revision$ $Date$ - * - * @author Phil Steitz - */ -public class TestTypedSortedSet extends AbstractTestSortedSet{ - - public TestTypedSortedSet(String testName) { - super(testName); - } - - public static Test suite() { - return BulkTest.makeSuite(TestTypedSortedSet.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTypedSortedSet.class.getName()}; - junit.textui.TestRunner.main(testCaseName); - } - - //------------------------------------------------------------------- - protected Class integerType = new Integer(0).getClass(); - - public Set makeEmptySet() { - return TypedSortedSet.decorate(new TreeSet(), integerType); - } - - public Set makeFullSet() { - TreeSet set = new TreeSet(); - set.addAll(Arrays.asList(getFullElements())); - return TypedSortedSet.decorate(set, integerType); - } - - -//-------------------------------------------------------------------- - protected Long getNextAsLong() { - SortedSet set = (SortedSet) makeFullSet(); - int nextValue = ((Integer)set.last()).intValue() + 1; - return new Long(nextValue); - } - - protected Integer getNextAsInt() { - SortedSet set = (SortedSet) makeFullSet(); - int nextValue = ((Integer)set.last()).intValue() + 1; - return new Integer(nextValue); - } - - public void testIllegalAdd() { - Set set = makeFullSet(); - try { - set.add(getNextAsLong()); - fail("Should fail type test."); - } catch (IllegalArgumentException e) { - // expected - } - assertTrue("Collection shouldn't convert long to int", - !set.contains(getNextAsInt())); - } - - public void testIllegalAddAll() { - Set set = makeFullSet(); - Set elements = new TreeSet(); - elements.add(getNextAsLong()); - try { - set.addAll(elements); - fail("Should fail type test."); - } catch (IllegalArgumentException e) { - // expected - } - assertTrue("Collection shouldn't convert long to int", - !set.contains(getNextAsInt())); - } - - public boolean skipSerializedCanonicalTests() { - return true; // Typed and Predicated get confused - } - -}