You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:30:02 UTC
svn commit: r814997 [1/18] - in /commons/proper/collections/trunk/src:
java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/
java/org/apache/commons/collections/bidimap/
java/org/apache/commons/collections/buffer/ java/org/apach...
Author: bayard
Date: Tue Sep 15 05:29:56 2009
New Revision: 814997
URL: http://svn.apache.org/viewvc?rev=814997&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified in commit r738956.
Added:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java
- copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractUntypedCollectionDecorator.java
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ArrayStack.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/BoundedCollection.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/Closure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ComparatorUtils.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/EnumerationUtils.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/Factory.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/Predicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/Transformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/HashBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TreeBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/TreeBidiMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/UnmodifiableBidiMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/UnmodifiableOrderedBidiMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/UnmodifiableSortedBidiMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/CircularFifoBuffer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/PriorityBuffer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/BooleanComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparableComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/FixedOrderComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/TransformingComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/AndPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/AnyPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ChainedClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ChainedTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/CloneTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ClosureTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ConstantFactory.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ConstantTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ExceptionClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ExceptionFactory.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ExceptionPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ExceptionTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/FactoryTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/FalsePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/ForClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/IdentityPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/IfClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstanceofPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InstantiateTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/InvokerTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/MapTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NOPClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NOPTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NonePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NotNullPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NotPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/OnePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/OrPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/PredicateTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/PrototypeFactory.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/StringValueTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/SwitchClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/SwitchTransformer.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/TransformedPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/TransformerClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/TransformerPredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/UniquePredicate.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/WhileClosure.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/AbstractEmptyIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/AbstractIteratorDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/AbstractMapIteratorDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/AbstractOrderedMapIteratorDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/CollatingIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EmptyIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EmptyListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EmptyMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EmptyOrderedIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EmptyOrderedMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EntrySetMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/FilterIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/FilterListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorChain.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorEnumeration.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ReverseListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/TransformIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UniqueFilterIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractKeyValue.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntry.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultKeyValue.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultMapEntry.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/MultiKey.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractLinkedList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/CursorableLinkedList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/TransformedList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/TreeList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/HashedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/IdentityMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LRUMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LinkedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/MultiKeyMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/PredicatedSortedMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/ReferenceIdentityMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/ReferenceMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/SingletonMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableMap.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/CompositeSet.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/MapBackedSet.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/TransformedSet.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/TransformedSortedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/AbstractTestObject.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/BulkTest.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/LocalTestNode.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayStack.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestBufferUtils.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestEnumerationUtils.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestLinkedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestSetUtils.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTreeMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTypedCollection.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestHashBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTreeBag.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestAbstractOrderedBidiMapDecorator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualHashBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestTreeBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestUnmodifiableBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestUnmodifiableOrderedBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestUnmodifiableSortedBidiMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestBlockingBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestBoundedBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestBoundedFifoBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestBoundedFifoBuffer2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestCircularFifoBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestPredicatedBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestPriorityBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestSynchronizedBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestTransformedBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestUnboundedFifoBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/buffer/TestUnmodifiableBuffer.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/comparators/TestBooleanComparator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/comparators/TestComparableComparator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/comparators/TestFixedOrderComparator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/comparators/TestReverseComparator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestArrayIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestArrayIterator2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestArrayListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestArrayListIterator2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestCollatingIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestIteratorChain.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestLoopingIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestLoopingListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectArrayIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestAbstractLinkedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestFixedSizeList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestGrowthList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestNodeCachingLinkedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestPredicatedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestSetUniqueList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestSynchronizedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestTransformedList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestSortedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeSortedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestHashedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestIdentityMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLRUMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLinkedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestListOrderedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestListOrderedMap2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestPredicatedSortedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceIdentityMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestSingletonMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestTransformedSortedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableOrderedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableSortedMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ArrayStack.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ArrayStack.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ArrayStack.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ArrayStack.java Tue Sep 15 05:29:56 2009
@@ -42,7 +42,7 @@
* @author Paul Jack
* @author Stephen Colebourne
*/
-public class ArrayStack extends ArrayList implements Buffer {
+public class ArrayStack<E> extends ArrayList<E> implements Buffer<E> {
/** Ensure serialization compatibility */
private static final long serialVersionUID = 2130079159931574599L;
@@ -84,7 +84,7 @@
* @return the top item on the stack
* @throws EmptyStackException if the stack is empty
*/
- public Object peek() throws EmptyStackException {
+ public E peek() throws EmptyStackException {
int n = size();
if (n <= 0) {
throw new EmptyStackException();
@@ -102,7 +102,7 @@
* @throws EmptyStackException if there are not enough items on the
* stack to satisfy this request
*/
- public Object peek(int n) throws EmptyStackException {
+ public E peek(int n) throws EmptyStackException {
int m = (size() - n) - 1;
if (m < 0) {
throw new EmptyStackException();
@@ -117,7 +117,7 @@
* @return the top item on the stack
* @throws EmptyStackException if the stack is empty
*/
- public Object pop() throws EmptyStackException {
+ public E pop() throws EmptyStackException {
int n = size();
if (n <= 0) {
throw new EmptyStackException();
@@ -133,7 +133,7 @@
* @param item the item to be added
* @return the item just pushed
*/
- public Object push(Object item) {
+ public E push(E item) {
add(item);
return item;
}
@@ -170,7 +170,7 @@
* @return the element on the top of the stack
* @throws BufferUnderflowException if the stack is empty
*/
- public Object get() {
+ public E get() {
int size = size();
if (size == 0) {
throw new BufferUnderflowException();
@@ -184,7 +184,7 @@
* @return the removed element
* @throws BufferUnderflowException if the stack is empty
*/
- public Object remove() {
+ public E remove() {
int size = size();
if (size == 0) {
throw new BufferUnderflowException();
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BoundedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BoundedCollection.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BoundedCollection.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BoundedCollection.java Tue Sep 15 05:29:56 2009
@@ -34,7 +34,7 @@
* @author Herve Quiroz
* @author Stephen Colebourne
*/
-public interface BoundedCollection extends Collection {
+public interface BoundedCollection<E> extends Collection<E> {
/**
* Returns true if this collection is full and no new elements can be added.
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java Tue Sep 15 05:29:56 2009
@@ -31,6 +31,9 @@
*/
public class BufferOverflowException extends RuntimeException {
+ /** Serialization version */
+ private static final long serialVersionUID = -3992254982265755876L;
+
/** The root cause throwable */
private final Throwable throwable;
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java Tue Sep 15 05:29:56 2009
@@ -34,6 +34,9 @@
*/
public class BufferUnderflowException extends NoSuchElementException {
+ /** Serialization version */
+ private static final long serialVersionUID = 4054570024234606028L;
+
/** The root cause throwable */
private final Throwable throwable;
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/Closure.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/Closure.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/Closure.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/Closure.java Tue Sep 15 05:29:56 2009
@@ -24,7 +24,8 @@
* <p>
* Standard implementations of common closures are provided by
* {@link ClosureUtils}. These include method invokation and for/while loops.
- *
+ *
+ * @param <T> the type that the closure acts on
* @since Commons Collections 1.0
* @version $Revision$ $Date$
*
@@ -32,7 +33,7 @@
* @author Nicola Ken Barozzi
* @author Stephen Colebourne
*/
-public interface Closure {
+public interface Closure<T> {
/**
* Performs an action on the specified input object.
@@ -42,6 +43,6 @@
* @throws IllegalArgumentException (runtime) if the input is invalid
* @throws FunctorException (runtime) if any other error occurs
*/
- public void execute(Object input);
+ public void execute(T input);
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ComparatorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ComparatorUtils.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ComparatorUtils.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ComparatorUtils.java Tue Sep 15 05:29:56 2009
@@ -54,14 +54,16 @@
*
* @see ComparableComparator#getInstance
*/
- public static final Comparator NATURAL_COMPARATOR = ComparableComparator.getInstance();
+ @SuppressWarnings("unchecked")
+ public static final Comparator NATURAL_COMPARATOR = ComparableComparator.<Comparable>getInstance();
/**
* Gets a comparator that uses the natural order of the objects.
*
* @return a comparator which uses natural order
*/
- public static Comparator naturalComparator() {
+ @SuppressWarnings("unchecked")
+ public static <E extends Comparable<? super E>> Comparator<E> naturalComparator() {
return NATURAL_COMPARATOR;
}
@@ -76,7 +78,8 @@
* @throws NullPointerException if either comparator is null
* @see ComparatorChain
*/
- public static Comparator chainedComparator(Comparator comparator1, Comparator comparator2) {
+ @SuppressWarnings("unchecked")
+ public static <E extends Comparable<? super E>> Comparator<E> chainedComparator(Comparator<E> comparator1, Comparator<E> comparator2) {
return chainedComparator(new Comparator[] {comparator1, comparator2});
}
@@ -89,8 +92,8 @@
* @throws NullPointerException if comparators array is null or contains a null
* @see ComparatorChain
*/
- public static Comparator chainedComparator(Comparator[] comparators) {
- ComparatorChain chain = new ComparatorChain();
+ public static <E extends Comparable<? super E>> Comparator<E> chainedComparator(Comparator<E>[] comparators) {
+ ComparatorChain<E> chain = new ComparatorChain<E>();
for (int i = 0; i < comparators.length; i++) {
if (comparators[i] == null) {
throw new NullPointerException("Comparator cannot be null");
@@ -111,9 +114,10 @@
* @throws ClassCastException if the comparators collection contains the wrong object type
* @see ComparatorChain
*/
- public static Comparator chainedComparator(Collection comparators) {
+ @SuppressWarnings("unchecked")
+ public static <E extends Comparable<? super E>> Comparator<E> chainedComparator(Collection<Comparator<E>> comparators) {
return chainedComparator(
- (Comparator[]) comparators.toArray(new Comparator[comparators.size()])
+ (Comparator<E>[]) comparators.toArray(new Comparator[comparators.size()])
);
}
@@ -124,11 +128,8 @@
* @return a comparator that reverses the order of the input comparator
* @see ReverseComparator
*/
- public static Comparator reversedComparator(Comparator comparator) {
- if (comparator == null) {
- comparator = NATURAL_COMPARATOR;
- }
- return new ReverseComparator(comparator);
+ public static <E> Comparator<E> reversedComparator(Comparator<E> comparator) {
+ return new ReverseComparator<E>(comparator);
}
/**
@@ -143,7 +144,7 @@
* <code>false</code> {@link Boolean}s.
* @return a comparator that sorts booleans
*/
- public static Comparator booleanComparator(boolean trueFirst) {
+ public static Comparator<Boolean> booleanComparator(boolean trueFirst) {
return BooleanComparator.getBooleanComparator(trueFirst);
}
@@ -158,11 +159,12 @@
* @return a version of that comparator that allows nulls
* @see NullComparator
*/
- public static Comparator nullLowComparator(Comparator comparator) {
+ @SuppressWarnings("unchecked")
+ public static <E> Comparator<E> nullLowComparator(Comparator<E> comparator) {
if (comparator == null) {
comparator = NATURAL_COMPARATOR;
}
- return new NullComparator(comparator, false);
+ return new NullComparator<E>(comparator, false);
}
/**
@@ -176,11 +178,12 @@
* @return a version of that comparator that allows nulls
* @see NullComparator
*/
- public static Comparator nullHighComparator(Comparator comparator) {
+ @SuppressWarnings("unchecked")
+ public static <E> Comparator<E> nullHighComparator(Comparator<E> comparator) {
if (comparator == null) {
comparator = NATURAL_COMPARATOR;
}
- return new NullComparator(comparator, true);
+ return new NullComparator<E>(comparator, true);
}
/**
@@ -195,11 +198,12 @@
* @return a comparator that transforms its input objects before comparing them
* @see TransformingComparator
*/
- public static Comparator transformedComparator(Comparator comparator, Transformer transformer) {
+ @SuppressWarnings("unchecked")
+ public static <E> Comparator<E> transformedComparator(Comparator<E> comparator, Transformer<? super E, ? extends E> transformer) {
if (comparator == null) {
comparator = NATURAL_COMPARATOR;
}
- return new TransformingComparator(transformer, comparator);
+ return new TransformingComparator<E>(transformer, comparator);
}
/**
@@ -212,7 +216,8 @@
* @param comparator the sort order to use
* @return the smaller of the two objects
*/
- public static Object min(Object o1, Object o2, Comparator comparator) {
+ @SuppressWarnings("unchecked")
+ public static <E> E min(E o1, E o2, Comparator<E> comparator) {
if (comparator == null) {
comparator = NATURAL_COMPARATOR;
}
@@ -230,7 +235,8 @@
* @param comparator the sort order to use
* @return the larger of the two objects
*/
- public static Object max(Object o1, Object o2, Comparator comparator) {
+ @SuppressWarnings("unchecked")
+ public static <E> E max(E o1, E o2, Comparator<E> comparator) {
if (comparator == null) {
comparator = NATURAL_COMPARATOR;
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/EnumerationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/EnumerationUtils.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/EnumerationUtils.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/EnumerationUtils.java Tue Sep 15 05:29:56 2009
@@ -16,8 +16,10 @@
*/
package org.apache.commons.collections;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.StringTokenizer;
import org.apache.commons.collections.iterators.EnumerationIterator;
@@ -47,8 +49,21 @@
* @param enumeration the enumeration to traverse, which should not be <code>null</code>.
* @throws NullPointerException if the enumeration parameter is <code>null</code>.
*/
- public static List toList(Enumeration enumeration) {
- return IteratorUtils.toList(new EnumerationIterator(enumeration));
+ public static <E> List<E> toList(Enumeration<E> enumeration) {
+ return IteratorUtils.toList(new EnumerationIterator<E>(enumeration));
}
+ /**
+ * Override toList(Enumeration) for StringTokenizer as it implements Enumeration<String>
+ * for the sake of backward compatibility.
+ * @param stringTokenizer
+ * @return List<String>
+ */
+ public static List<String> toList(StringTokenizer stringTokenizer) {
+ List<String> result = new ArrayList<String>(stringTokenizer.countTokens());
+ while (stringTokenizer.hasMoreTokens()) {
+ result.add(stringTokenizer.nextToken());
+ }
+ return result;
+ }
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/Factory.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/Factory.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/Factory.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/Factory.java Tue Sep 15 05:29:56 2009
@@ -26,13 +26,15 @@
* {@link FactoryUtils}. These include factories that return a constant,
* a copy of a prototype or a new instance.
*
+ * @param <T> the type that the factory creates
+ *
* @since Commons Collections 2.1
* @version $Revision$ $Date$
*
* @author Arron Bates
* @author Stephen Colebourne
*/
-public interface Factory {
+public interface Factory<T> {
/**
* Create a new object.
@@ -40,6 +42,6 @@
* @return a new object
* @throws FunctorException (runtime) if the factory cannot create an object
*/
- public Object create();
+ public T create();
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java Tue Sep 15 05:29:56 2009
@@ -30,11 +30,14 @@
*/
public class FunctorException extends RuntimeException {
+ /** Serialization version */
+ private static final long serialVersionUID = 9139387246344345475L;
+
/**
* Does JDK support nested exceptions
*/
private static final boolean JDK_SUPPORTS_NESTED;
-
+
static {
boolean flag = false;
try {
@@ -45,7 +48,7 @@
}
JDK_SUPPORTS_NESTED = flag;
}
-
+
/**
* Root cause of the exception
*/
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/Predicate.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/Predicate.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/Predicate.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/Predicate.java Tue Sep 15 05:29:56 2009
@@ -28,13 +28,15 @@
* {@link PredicateUtils}. These include true, false, instanceof, equals, and,
* or, not, method invokation and null testing.
*
+ * @param <T> the type that the predicate queries
+ *
* @since Commons Collections 1.0
* @version $Revision$ $Date$
*
* @author James Strachan
* @author Stephen Colebourne
*/
-public interface Predicate {
+public interface Predicate<T> {
/**
* Use the specified parameter to perform a test that returns true or false.
@@ -45,6 +47,6 @@
* @throws IllegalArgumentException (runtime) if the input is invalid
* @throws FunctorException (runtime) if the predicate encounters a problem
*/
- public boolean evaluate(Object object);
+ public boolean evaluate(T object);
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/Transformer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/Transformer.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/Transformer.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/Transformer.java Tue Sep 15 05:29:56 2009
@@ -29,13 +29,16 @@
* {@link TransformerUtils}. These include method invokation, returning a constant,
* cloning and returning the string value.
*
+ * @param <I> the input type to the transformer
+ * @param <O> the output type from the transformer
+ *
* @since Commons Collections 1.0
* @version $Revision$ $Date$
*
* @author James Strachan
* @author Stephen Colebourne
*/
-public interface Transformer {
+public interface Transformer<I, O> {
/**
* Transforms the input object (leaving it unchanged) into some output object.
@@ -46,6 +49,6 @@
* @throws IllegalArgumentException (runtime) if the input is invalid
* @throws FunctorException (runtime) if the transform cannot be completed
*/
- public Object transform(Object input);
+ public O transform(I input);
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java Tue Sep 15 05:29:56 2009
@@ -33,9 +33,9 @@
* Abstract implementation of the {@link Bag} interface to simplify the creation
* of subclass implementations.
* <p>
- * Subclasses specify a Map implementation to use as the internal storage.
- * The map will be used to map bag elements to a number; the number represents
- * the number of occurrences of that element in the bag.
+ * Subclasses specify a Map implementation to use as the internal storage. The
+ * map will be used to map bag elements to a number; the number represents the
+ * number of occurrences of that element in the bag.
*
* @since Commons Collections 3.0 (previously DefaultMapBag v2.0)
* @version $Revision$ $Date$
@@ -46,16 +46,16 @@
* @author Janek Bogucki
* @author Steve Clark
*/
-public abstract class AbstractMapBag implements Bag {
-
+public abstract class AbstractMapBag<E> implements Bag<E> {
+
/** The map to use to store the data */
- private transient Map map;
+ private transient Map<E, MutableInteger> map;
/** The current total size of the bag */
private int size;
/** The modification count for fail fast iterators */
private transient int modCount;
/** The modification count for fail fast iterators */
- private transient Set uniqueSet;
+ private transient Set<E> uniqueSet;
/**
* Constructor needed for subclass serialisation.
@@ -66,30 +66,30 @@
}
/**
- * Constructor that assigns the specified Map as the backing store.
- * The map must be empty and non-null.
+ * Constructor that assigns the specified Map as the backing store. The map
+ * must be empty and non-null.
*
- * @param map the map to assign
+ * @param map the map to assign
*/
- protected AbstractMapBag(Map map) {
+ protected AbstractMapBag(Map<E, MutableInteger> map) {
super();
this.map = map;
}
/**
- * Utility method for implementations to access the map that backs
- * this bag. Not intended for interactive use outside of subclasses.
+ * Utility method for implementations to access the map that backs this bag.
+ * Not intended for interactive use outside of subclasses.
*
* @return the map being used by the Bag
*/
- protected Map getMap() {
+ protected Map<E, MutableInteger> getMap() {
return map;
}
//-----------------------------------------------------------------------
/**
* Returns the number of elements in this bag.
- *
+ *
* @return current size of the bag
*/
public int size() {
@@ -98,7 +98,7 @@
/**
* Returns true if the underlying map is empty.
- *
+ *
* @return true if bag is empty
*/
public boolean isEmpty() {
@@ -106,14 +106,14 @@
}
/**
- * Returns the number of occurrence of the given element in this bag
- * by looking up its count in the underlying map.
- *
- * @param object the object to search for
+ * Returns the number of occurrence of the given element in this bag by
+ * looking up its count in the underlying map.
+ *
+ * @param object the object to search for
* @return the number of occurrences of the object, zero if not found
*/
public int getCount(Object object) {
- MutableInteger count = (MutableInteger) map.get(object);
+ MutableInteger count = map.get(object);
if (count != null) {
return count.value;
}
@@ -124,8 +124,8 @@
/**
* Determines if the bag contains the given element by checking if the
* underlying map contains the element as a key.
- *
- * @param object the object to search for
+ *
+ * @param object the object to search for
* @return true if the bag contains the given element
*/
public boolean contains(Object object) {
@@ -135,26 +135,27 @@
/**
* Determines if the bag contains the given elements.
*
- * @param coll the collection to check against
+ * @param coll the collection to check against
* @return <code>true</code> if the Bag contains all the collection
*/
- public boolean containsAll(Collection coll) {
+ @SuppressWarnings("unchecked")
+ public boolean containsAll(Collection<?> coll) {
if (coll instanceof Bag) {
- return containsAll((Bag) coll);
+ return containsAll((Bag<?>) coll);
}
- return containsAll(new HashBag(coll));
+ return containsAll(new HashBag<Object>((Collection<Object>) coll));
}
/**
- * Returns <code>true</code> if the bag contains all elements in
- * the given collection, respecting cardinality.
+ * Returns <code>true</code> if the bag contains all elements in the given
+ * collection, respecting cardinality.
*
- * @param other the bag to check against
+ * @param other the bag to check against
* @return <code>true</code> if the Bag contains all the collection
*/
- boolean containsAll(Bag other) {
+ boolean containsAll(Bag<?> other) {
boolean result = true;
- Iterator it = other.uniqueSet().iterator();
+ Iterator<?> it = other.uniqueSet().iterator();
while (it.hasNext()) {
Object current = it.next();
boolean contains = getCount(current) >= other.getCount(current);
@@ -165,22 +166,22 @@
//-----------------------------------------------------------------------
/**
- * Gets an iterator over the bag elements.
- * Elements present in the Bag more than once will be returned repeatedly.
+ * Gets an iterator over the bag elements. Elements present in the Bag more
+ * than once will be returned repeatedly.
*
* @return the iterator
*/
- public Iterator iterator() {
- return new BagIterator(this);
+ public Iterator<E> iterator() {
+ return new BagIterator<E>(this);
}
/**
* Inner class iterator for the Bag.
*/
- static class BagIterator implements Iterator {
- private AbstractMapBag parent;
- private Iterator entryIterator;
- private Map.Entry current;
+ static class BagIterator<E> implements Iterator<E> {
+ private AbstractMapBag<E> parent;
+ private Iterator<Map.Entry<E, MutableInteger>> entryIterator;
+ private Map.Entry<E, MutableInteger> current;
private int itemCount;
private final int mods;
private boolean canRemove;
@@ -188,9 +189,9 @@
/**
* Constructor.
*
- * @param parent the parent bag
+ * @param parent the parent bag
*/
- public BagIterator(AbstractMapBag parent) {
+ public BagIterator(AbstractMapBag<E> parent) {
this.parent = parent;
this.entryIterator = parent.map.entrySet().iterator();
this.current = null;
@@ -202,13 +203,13 @@
return (itemCount > 0 || entryIterator.hasNext());
}
- public Object next() {
+ public E next() {
if (parent.modCount != mods) {
throw new ConcurrentModificationException();
}
if (itemCount == 0) {
- current = (Map.Entry) entryIterator.next();
- itemCount = ((MutableInteger) current.getValue()).value;
+ current = (Map.Entry<E, MutableInteger>) entryIterator.next();
+ itemCount = current.getValue().value;
}
canRemove = true;
itemCount--;
@@ -222,7 +223,7 @@
if (canRemove == false) {
throw new IllegalStateException();
}
- MutableInteger mut = (MutableInteger) current.getValue();
+ MutableInteger mut = current.getValue();
if (mut.value > 1) {
mut.value--;
} else {
@@ -235,48 +236,49 @@
//-----------------------------------------------------------------------
/**
- * Adds a new element to the bag, incrementing its count in the underlying map.
- *
- * @param object the object to add
- * @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
+ * Adds a new element to the bag, incrementing its count in the underlying
+ * map.
+ *
+ * @param object the object to add
+ * @return <code>true</code> if the object was not already in the
+ * <code>uniqueSet</code>
*/
- public boolean add(Object object) {
+ public boolean add(E object) {
return add(object, 1);
}
/**
* Adds a new element to the bag, incrementing its count in the map.
- *
- * @param object the object to search for
- * @param nCopies the number of copies to add
- * @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
+ *
+ * @param object the object to search for
+ * @param nCopies the number of copies to add
+ * @return <code>true</code> if the object was not already in the
+ * <code>uniqueSet</code>
*/
- public boolean add(Object object, int nCopies) {
+ public boolean add(E object, int nCopies) {
modCount++;
if (nCopies > 0) {
- MutableInteger mut = (MutableInteger) map.get(object);
+ MutableInteger mut = map.get(object);
size += nCopies;
if (mut == null) {
map.put(object, new MutableInteger(nCopies));
return true;
- } else {
- mut.value += nCopies;
- return false;
}
- } else {
+ mut.value += nCopies;
return false;
}
+ return false;
}
/**
* Invokes {@link #add(Object)} for each element in the given collection.
- *
- * @param coll the collection to add
+ *
+ * @param coll the collection to add
* @return <code>true</code> if this call changed the bag
*/
- public boolean addAll(Collection coll) {
+ public boolean addAll(Collection<? extends E> coll) {
boolean changed = false;
- Iterator i = coll.iterator();
+ Iterator<? extends E> i = coll.iterator();
while (i.hasNext()) {
boolean added = add(i.next());
changed = changed || added;
@@ -297,11 +299,11 @@
/**
* Removes all copies of the specified object from the bag.
*
- * @param object the object to remove
+ * @param object the object to remove
* @return true if the bag changed
*/
public boolean remove(Object object) {
- MutableInteger mut = (MutableInteger) map.get(object);
+ MutableInteger mut = map.get(object);
if (mut == null) {
return false;
}
@@ -314,12 +316,12 @@
/**
* Removes a specified number of copies of an object from the bag.
*
- * @param object the object to remove
- * @param nCopies the number of copies to remove
+ * @param object the object to remove
+ * @param nCopies the number of copies to remove
* @return true if the bag changed
*/
public boolean remove(Object object, int nCopies) {
- MutableInteger mut = (MutableInteger) map.get(object);
+ MutableInteger mut = map.get(object);
if (mut == null) {
return false;
}
@@ -338,15 +340,16 @@
}
/**
- * Removes objects from the bag according to their count in the specified collection.
+ * Removes objects from the bag according to their count in the specified
+ * collection.
*
- * @param coll the collection to use
+ * @param coll the collection to use
* @return true if the bag changed
*/
- public boolean removeAll(Collection coll) {
+ public boolean removeAll(Collection<?> coll) {
boolean result = false;
if (coll != null) {
- Iterator i = coll.iterator();
+ Iterator<?> i = coll.iterator();
while (i.hasNext()) {
boolean changed = remove(i.next(), 1);
result = result || changed;
@@ -356,33 +359,34 @@
}
/**
- * Remove any members of the bag that are not in the given
- * bag, respecting cardinality.
- *
- * @param coll the collection to retain
+ * Remove any members of the bag that are not in the given bag, respecting
+ * cardinality.
+ *
+ * @param coll the collection to retain
* @return true if this call changed the collection
*/
- public boolean retainAll(Collection coll) {
+ @SuppressWarnings("unchecked")
+ public boolean retainAll(Collection<?> coll) {
if (coll instanceof Bag) {
- return retainAll((Bag) coll);
+ return retainAll((Bag<?>) coll);
}
- return retainAll(new HashBag(coll));
+ return retainAll(new HashBag<Object>((Collection<Object>) coll));
}
/**
- * Remove any members of the bag that are not in the given
- * bag, respecting cardinality.
+ * Remove any members of the bag that are not in the given bag, respecting
+ * cardinality.
* @see #retainAll(Collection)
*
- * @param other the bag to retain
+ * @param other the bag to retain
* @return <code>true</code> if this call changed the collection
*/
- boolean retainAll(Bag other) {
+ boolean retainAll(Bag<?> other) {
boolean result = false;
- Bag excess = new HashBag();
- Iterator i = uniqueSet().iterator();
+ Bag<E> excess = new HashBag<E>();
+ Iterator<E> i = uniqueSet().iterator();
while (i.hasNext()) {
- Object current = i.next();
+ E current = i.next();
int myCount = getCount(current);
int otherCount = other.getCount(current);
if (1 <= otherCount && otherCount <= myCount) {
@@ -404,15 +408,15 @@
protected static class MutableInteger {
/** The value of this mutable. */
protected int value;
-
+
/**
* Constructor.
- * @param value the initial value
+ * @param value the initial value
*/
MutableInteger(int value) {
this.value = value;
}
-
+
public boolean equals(Object obj) {
if (obj instanceof MutableInteger == false) {
return false;
@@ -424,19 +428,19 @@
return value;
}
}
-
+
//-----------------------------------------------------------------------
/**
* Returns an array of all of this bag's elements.
- *
+ *
* @return an array of all of this bag's elements
*/
public Object[] toArray() {
Object[] result = new Object[size()];
int i = 0;
- Iterator it = map.keySet().iterator();
+ Iterator<E> it = map.keySet().iterator();
while (it.hasNext()) {
- Object current = it.next();
+ E current = it.next();
for (int index = getCount(current); index > 0; index--) {
result[i++] = current;
}
@@ -446,38 +450,39 @@
/**
* Returns an array of all of this bag's elements.
- *
- * @param array the array to populate
+ *
+ * @param array the array to populate
* @return an array of all of this bag's elements
*/
- public Object[] toArray(Object[] array) {
+ @SuppressWarnings("unchecked")
+ public <T> T[] toArray(T[] array) {
int size = size();
if (array.length < size) {
- array = (Object[]) Array.newInstance(array.getClass().getComponentType(), size);
+ array = (T[]) Array.newInstance(array.getClass().getComponentType(), size);
}
int i = 0;
- Iterator it = map.keySet().iterator();
+ Iterator<E> it = map.keySet().iterator();
while (it.hasNext()) {
- Object current = it.next();
+ E current = it.next();
for (int index = getCount(current); index > 0; index--) {
- array[i++] = current;
+ array[i++] = (T) current;
}
}
- if (array.length > size) {
- array[size] = null;
+ while (i < array.length) {
+ array[i++] = null;
}
return array;
}
/**
* Returns an unmodifiable view of the underlying map's key set.
- *
+ *
* @return the set of unique elements in this bag
*/
- public Set uniqueSet() {
+ public Set<E> uniqueSet() {
if (uniqueSet == null) {
- uniqueSet = UnmodifiableSet.decorate(map.keySet());
+ uniqueSet = UnmodifiableSet.<E> decorate(map.keySet());
}
return uniqueSet;
}
@@ -485,26 +490,28 @@
//-----------------------------------------------------------------------
/**
* Write the map out using a custom routine.
- * @param out the output stream
+ * @param out the output stream
* @throws IOException
*/
protected void doWriteObject(ObjectOutputStream out) throws IOException {
out.writeInt(map.size());
- for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
+ for (Iterator<Map.Entry<E, MutableInteger>> it = map.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<E, MutableInteger> entry = it.next();
out.writeObject(entry.getKey());
- out.writeInt(((MutableInteger) entry.getValue()).value);
+ out.writeInt(entry.getValue().value);
}
}
/**
* Read the map in using a custom routine.
- * @param map the map to use
- * @param in the input stream
+ * @param map the map to use
+ * @param in the input stream
* @throws IOException
* @throws ClassNotFoundException
*/
- protected void doReadObject(Map map, ObjectInputStream in) throws IOException, ClassNotFoundException {
+ @SuppressWarnings("unchecked")
+ protected void doReadObject(Map map, ObjectInputStream in) throws IOException,
+ ClassNotFoundException {
this.map = map;
int entrySize = in.readInt();
for (int i = 0; i < entrySize; i++) {
@@ -514,14 +521,13 @@
size += count;
}
}
-
+
//-----------------------------------------------------------------------
/**
- * Compares this Bag to another.
- * This Bag equals another Bag if it contains the same number of occurrences of
- * the same elements.
+ * Compares this Bag to another. This Bag equals another Bag if it contains
+ * the same number of occurrences of the same elements.
*
- * @param object the Bag to compare to
+ * @param object the Bag to compare to
* @return true if equal
*/
public boolean equals(Object object) {
@@ -531,12 +537,12 @@
if (object instanceof Bag == false) {
return false;
}
- Bag other = (Bag) object;
+ Bag<?> other = (Bag<?>) object;
if (other.size() != size()) {
return false;
}
- for (Iterator it = map.keySet().iterator(); it.hasNext();) {
- Object element = it.next();
+ for (Iterator<E> it = map.keySet().iterator(); it.hasNext();) {
+ E element = it.next();
if (other.getCount(element) != getCount(element)) {
return false;
}
@@ -546,19 +552,19 @@
/**
* Gets a hash code for the Bag compatible with the definition of equals.
- * The hash code is defined as the sum total of a hash code for each element.
- * The per element hash code is defined as
- * <code>(e==null ? 0 : e.hashCode()) ^ noOccurances)</code>.
- * This hash code is compatible with the Set interface.
+ * The hash code is defined as the sum total of a hash code for each
+ * element. The per element hash code is defined as
+ * <code>(e==null ? 0 : e.hashCode()) ^ noOccurances)</code>. This hash code
+ * is compatible with the Set interface.
*
* @return the hash code of the Bag
*/
public int hashCode() {
int total = 0;
- for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- Object element = entry.getKey();
- MutableInteger count = (MutableInteger) entry.getValue();
+ for (Iterator<Map.Entry<E, MutableInteger>> it = map.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<E, MutableInteger> entry = it.next();
+ E element = entry.getKey();
+ MutableInteger count = entry.getValue();
total += (element == null ? 0 : element.hashCode()) ^ count.value;
}
return total;
@@ -575,7 +581,7 @@
}
StringBuffer buf = new StringBuffer();
buf.append('[');
- Iterator it = uniqueSet().iterator();
+ Iterator<E> it = uniqueSet().iterator();
while (it.hasNext()) {
Object current = it.next();
int count = getCount(current);
@@ -589,5 +595,5 @@
buf.append(']');
return buf.toString();
}
-
+
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/HashBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/HashBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/HashBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/HashBag.java Tue Sep 15 05:29:56 2009
@@ -41,8 +41,8 @@
* @author Chuck Burdick
* @author Stephen Colebourne
*/
-public class HashBag
- extends AbstractMapBag implements Bag, Serializable {
+public class HashBag<E>
+ extends AbstractMapBag<E> implements Bag<E>, Serializable {
/** Serial version lock */
private static final long serialVersionUID = -6561115435802554013L;
@@ -51,7 +51,7 @@
* Constructs an empty <code>HashBag</code>.
*/
public HashBag() {
- super(new HashMap());
+ super(new HashMap<E, MutableInteger>());
}
/**
@@ -59,7 +59,7 @@
*
* @param coll a collection to copy into this bag
*/
- public HashBag(Collection coll) {
+ public HashBag(Collection<? extends E> coll) {
this();
addAll(coll);
}
@@ -78,7 +78,7 @@
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- super.doReadObject(new HashMap(), in);
+ super.doReadObject(new HashMap<E, MutableInteger>(), in);
}
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedBag.java Tue Sep 15 05:29:56 2009
@@ -38,8 +38,8 @@
*
* @author Stephen Colebourne
*/
-public class TransformedBag
- extends TransformedCollection implements Bag {
+public class TransformedBag<E>
+ extends TransformedCollection<E> implements Bag<E> {
/** Serialization version */
private static final long serialVersionUID = 5421170911299074185L;
@@ -56,8 +56,8 @@
* @return a new transformed Bag
* @throws IllegalArgumentException if bag or transformer is null
*/
- public static Bag decorate(Bag bag, Transformer transformer) {
- return new TransformedBag(bag, transformer);
+ public static <E> Bag<E> decorate(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
+ return new TransformedBag<E>(bag, transformer);
}
/**
@@ -74,13 +74,14 @@
* @throws IllegalArgumentException if bag or transformer is null
* @since Commons Collections 3.3
*/
+ // TODO: Generics
public static Bag decorateTransform(Bag bag, Transformer transformer) {
TransformedBag decorated = new TransformedBag(bag, transformer);
if (transformer != null && bag != null && bag.size() > 0) {
Object[] values = bag.toArray();
bag.clear();
for(int i=0; i<values.length; i++) {
- decorated.getCollection().add(transformer.transform(values[i]));
+ decorated.decorated().add(transformer.transform(values[i]));
}
}
return decorated;
@@ -97,7 +98,7 @@
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if bag or transformer is null
*/
- protected TransformedBag(Bag bag, Transformer transformer) {
+ protected TransformedBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
super(bag, transformer);
}
@@ -106,8 +107,8 @@
*
* @return the decorated bag
*/
- protected Bag getBag() {
- return (Bag) collection;
+ protected Bag<E> getBag() {
+ return (Bag<E>) collection;
}
//-----------------------------------------------------------------------
@@ -120,14 +121,13 @@
}
//-----------------------------------------------------------------------
- public boolean add(Object object, int nCopies) {
- object = transform(object);
- return getBag().add(object, nCopies);
+ public boolean add(E object, int nCopies) {
+ return getBag().add(transform(object), nCopies);
}
- public Set uniqueSet() {
- Set set = getBag().uniqueSet();
- return TransformedSet.decorate(set, transformer);
+ public Set<E> uniqueSet() {
+ Set<E> set = getBag().uniqueSet();
+ return TransformedSet.<E>decorate(set, transformer);
}
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java Tue Sep 15 05:29:56 2009
@@ -36,8 +36,8 @@
*
* @author Stephen Colebourne
*/
-public class TransformedSortedBag
- extends TransformedBag implements SortedBag {
+public class TransformedSortedBag<E>
+ extends TransformedBag<E> implements SortedBag<E> {
/** Serialization version */
private static final long serialVersionUID = -251737742649401930L;
@@ -54,8 +54,8 @@
* @return a new transformed SortedBag
* @throws IllegalArgumentException if bag or transformer is null
*/
- public static SortedBag decorate(SortedBag bag, Transformer transformer) {
- return new TransformedSortedBag(bag, transformer);
+ public static <E> SortedBag<E> decorate(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
+ return new TransformedSortedBag<E>(bag, transformer);
}
/**
@@ -72,13 +72,14 @@
* @throws IllegalArgumentException if bag or transformer is null
* @since Commons Collections 3.3
*/
+ // TODO: Generics
public static SortedBag decorateTransform(SortedBag bag, Transformer transformer) {
TransformedSortedBag decorated = new TransformedSortedBag(bag, transformer);
if (transformer != null && bag != null && bag.size() > 0) {
Object[] values = bag.toArray();
bag.clear();
for(int i=0; i<values.length; i++) {
- decorated.getCollection().add(transformer.transform(values[i]));
+ decorated.decorated().add(transformer.transform(values[i]));
}
}
return decorated;
@@ -95,7 +96,7 @@
* @param transformer the transformer to use for conversion, must not be null
* @throws IllegalArgumentException if bag or transformer is null
*/
- protected TransformedSortedBag(SortedBag bag, Transformer transformer) {
+ protected TransformedSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
super(bag, transformer);
}
@@ -104,20 +105,20 @@
*
* @return the decorated bag
*/
- protected SortedBag getSortedBag() {
- return (SortedBag) collection;
+ protected SortedBag<E> getSortedBag() {
+ return (SortedBag<E>) collection;
}
//-----------------------------------------------------------------------
- public Object first() {
+ public E first() {
return getSortedBag().first();
}
- public Object last() {
+ public E last() {
return getSortedBag().last();
}
- public Comparator comparator() {
+ public Comparator<? super E> comparator() {
return getSortedBag().comparator();
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TreeBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TreeBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TreeBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/TreeBag.java Tue Sep 15 05:29:56 2009
@@ -34,11 +34,11 @@
* Order will be maintained among the bag members and can be viewed through the
* iterator.
* <p>
- * A <code>Bag</code> stores each object in the collection together with a
- * count of occurrences. Extra methods on the interface allow multiple copies
- * of an object to be added or removed at once. It is important to read the
- * interface javadoc carefully as several methods violate the
- * <code>Collection</code> interface specification.
+ * A <code>Bag</code> stores each object in the collection together with a count
+ * of occurrences. Extra methods on the interface allow multiple copies of an
+ * object to be added or removed at once. It is important to read the interface
+ * javadoc carefully as several methods violate the <code>Collection</code>
+ * interface specification.
*
* @since Commons Collections 3.0 (previously in main package v2.0)
* @version $Revision$ $Date$
@@ -46,60 +46,69 @@
* @author Chuck Burdick
* @author Stephen Colebourne
*/
-public class TreeBag
- extends AbstractMapBag implements SortedBag, Serializable {
+public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Serializable {
/** Serial version lock */
private static final long serialVersionUID = -7740146511091606676L;
-
+
/**
* Constructs an empty <code>TreeBag</code>.
*/
public TreeBag() {
- super(new TreeMap());
+ super(new TreeMap<E, MutableInteger>());
}
/**
- * Constructs an empty bag that maintains order on its unique
- * representative members according to the given {@link Comparator}.
+ * Constructs an empty bag that maintains order on its unique representative
+ * members according to the given {@link Comparator}.
*
- * @param comparator the comparator to use
+ * @param comparator the comparator to use
*/
- public TreeBag(Comparator comparator) {
- super(new TreeMap(comparator));
+ public TreeBag(Comparator<? super E> comparator) {
+ super(new TreeMap<E, MutableInteger>(comparator));
}
/**
* Constructs a <code>TreeBag</code> containing all the members of the
* specified collection.
*
- * @param coll the collection to copy into the bag
+ * @param coll the collection to copy into the bag
*/
- public TreeBag(Collection coll) {
+ public TreeBag(Collection<? extends E> coll) {
this();
addAll(coll);
}
//-----------------------------------------------------------------------
- public boolean add(Object o) {
- if(comparator() == null && !(o instanceof Comparable)) {
- throw new IllegalArgumentException("Objects of type " + o.getClass() + " cannot be added to " +
+ // TODO: Generics - should this be E<? extends Comparable> or some such?
+ public boolean add(E object) {
+ if(comparator() == null && !(object instanceof Comparable)) {
+ throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
"a naturally ordered TreeBag as it does not implement Comparable");
}
- return super.add(o);
+ return super.add(object);
}
//-----------------------------------------------------------------------
- public Object first() {
- return ((SortedMap) getMap()).firstKey();
+ public E first() {
+ return getMap().firstKey();
+ }
+
+ public E last() {
+ return getMap().lastKey();
}
- public Object last() {
- return ((SortedMap) getMap()).lastKey();
+ public Comparator<? super E> comparator() {
+ return getMap().comparator();
}
- public Comparator comparator() {
- return ((SortedMap) getMap()).comparator();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected SortedMap<E, org.apache.commons.collections.bag.AbstractMapBag.MutableInteger> getMap() {
+ return (SortedMap<E, org.apache.commons.collections.bag.AbstractMapBag.MutableInteger>) super
+ .getMap();
}
//-----------------------------------------------------------------------
@@ -115,10 +124,11 @@
/**
* Read the bag in using a custom routine.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
Comparator comp = (Comparator) in.readObject();
super.doReadObject(new TreeMap(comp), in);
}
-
+
}
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java Tue Sep 15 05:29:56 2009
@@ -42,8 +42,7 @@
* @author Matthew Hawthorne
* @author Stephen Colebourne
*/
-public class DualHashBidiMap
- extends AbstractDualBidiMap implements Serializable {
+public class DualHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements Serializable {
/** Ensure serialization compatibility */
private static final long serialVersionUID = 721969328361808L;
@@ -52,7 +51,7 @@
* Creates an empty <code>HashBidiMap</code>.
*/
public DualHashBidiMap() {
- super(new HashMap(), new HashMap());
+ super(new HashMap<K, V>(), new HashMap<V, K>());
}
/**
@@ -61,8 +60,8 @@
*
* @param map the map whose mappings are to be placed in this map
*/
- public DualHashBidiMap(Map map) {
- super(new HashMap(), new HashMap());
+ public DualHashBidiMap(Map<K, V> map) {
+ super(new HashMap<K, V>(), new HashMap<V, K>());
putAll(map);
}
@@ -73,7 +72,7 @@
* @param reverseMap the reverse direction map
* @param inverseBidiMap the inverse BidiMap
*/
- protected DualHashBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap) {
+ protected DualHashBidiMap(Map<K, V> normalMap, Map<V, K> reverseMap, BidiMap<V, K> inverseBidiMap) {
super(normalMap, reverseMap, inverseBidiMap);
}
@@ -85,21 +84,22 @@
* @param inverseBidiMap the inverse BidiMap
* @return new bidi map
*/
- protected BidiMap createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap) {
- return new DualHashBidiMap(normalMap, reverseMap, inverseBidiMap);
+ protected BidiMap<V, K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseBidiMap) {
+ return new DualHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
}
// Serialization
//-----------------------------------------------------------------------
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
- out.writeObject(maps[0]);
+ out.writeObject(normalMap);
}
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- maps[0] = new HashMap();
- maps[1] = new HashMap();
+ normalMap = new HashMap();
+ reverseMap = new HashMap();
Map map = (Map) in.readObject();
putAll(map);
}