From 902ee25dcfb3f2a14d3dd8a9778f16b68611baaa Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Sat, 23 Jun 2012 14:33:48 +0000 Subject: [PATCH] [COLLECTIONS-231] return specific type rather than base type in factory methods. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1353132 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/collections/map/DefaultedMap.java | 4 ++-- .../org/apache/commons/collections/map/FixedSizeMap.java | 2 +- .../apache/commons/collections/map/FixedSizeSortedMap.java | 2 +- .../org/apache/commons/collections/map/LazySortedMap.java | 5 +++-- .../org/apache/commons/collections/map/ListOrderedMap.java | 2 +- .../org/apache/commons/collections/map/MultiValueMap.java | 6 ++++-- .../org/apache/commons/collections/map/PredicatedMap.java | 4 +++- .../apache/commons/collections/map/PredicatedSortedMap.java | 2 +- .../org/apache/commons/collections/map/TransformedMap.java | 4 ++-- .../commons/collections/map/TransformedSortedMap.java | 4 ++-- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/collections/map/DefaultedMap.java b/src/main/java/org/apache/commons/collections/map/DefaultedMap.java index eb99c1bc6..5a1c25d66 100644 --- a/src/main/java/org/apache/commons/collections/map/DefaultedMap.java +++ b/src/main/java/org/apache/commons/collections/map/DefaultedMap.java @@ -82,7 +82,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se * @param defaultValue the default value to return when the key is not found * @throws IllegalArgumentException if map is null */ - public static Map defaultedMap(Map map, V defaultValue) { + public static DefaultedMap defaultedMap(Map map, V defaultValue) { return new DefaultedMap(map, ConstantTransformer.constantTransformer(defaultValue)); } @@ -96,7 +96,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se * @param factory the factory to use to create entries, must not be null * @throws IllegalArgumentException if map or factory is null */ - public static IterableMap defaultedMap(Map map, Factory factory) { + public static DefaultedMap defaultedMap(Map map, Factory factory) { if (factory == null) { throw new IllegalArgumentException("Factory must not be null"); } diff --git a/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java b/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java index f9647442e..3e3920e8f 100644 --- a/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java +++ b/src/main/java/org/apache/commons/collections/map/FixedSizeMap.java @@ -69,7 +69,7 @@ public class FixedSizeMap * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ - public static IterableMap fixedSizeMap(Map map) { + public static FixedSizeMap fixedSizeMap(Map map) { return new FixedSizeMap(map); } diff --git a/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java b/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java index 52cd6a69b..6111867e5 100644 --- a/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java +++ b/src/main/java/org/apache/commons/collections/map/FixedSizeSortedMap.java @@ -70,7 +70,7 @@ public class FixedSizeSortedMap * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ - public static SortedMap fixedSizeSortedMap(SortedMap map) { + public static FixedSizeSortedMap fixedSizeSortedMap(SortedMap map) { return new FixedSizeSortedMap(map); } diff --git a/src/main/java/org/apache/commons/collections/map/LazySortedMap.java b/src/main/java/org/apache/commons/collections/map/LazySortedMap.java index 31f0176a2..e2910833a 100644 --- a/src/main/java/org/apache/commons/collections/map/LazySortedMap.java +++ b/src/main/java/org/apache/commons/collections/map/LazySortedMap.java @@ -72,7 +72,7 @@ public class LazySortedMap * @param factory the factory to use, must not be null * @throws IllegalArgumentException if map or factory is null */ - public static SortedMap lazySortedMap(SortedMap map, Factory factory) { + public static LazySortedMap lazySortedMap(SortedMap map, Factory factory) { return new LazySortedMap(map, factory); } @@ -83,7 +83,8 @@ public class LazySortedMap * @param factory the factory to use, must not be null * @throws IllegalArgumentException if map or factory is null */ - public static SortedMap lazySortedMap(SortedMap map, Transformer factory) { + public static LazySortedMap lazySortedMap(SortedMap map, + Transformer factory) { return new LazySortedMap(map, factory); } diff --git a/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java b/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java index b7606b24a..4236ea2a4 100644 --- a/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java +++ b/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java @@ -96,7 +96,7 @@ public class ListOrderedMap * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ - public static OrderedMap listOrderedMap(Map map) { + public static ListOrderedMap listOrderedMap(Map map) { return new ListOrderedMap(map); } diff --git a/src/main/java/org/apache/commons/collections/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections/map/MultiValueMap.java index e0033e360..a6ec79217 100644 --- a/src/main/java/org/apache/commons/collections/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections/map/MultiValueMap.java @@ -95,7 +95,8 @@ public class MultiValueMap extends AbstractMapDecorator impleme * @param map the map to wrap * @param collectionClass the type of the collection class */ - public static > MultiValueMap multiValueMap(Map map, Class collectionClass) { + public static > MultiValueMap multiValueMap(Map map, + Class collectionClass) { return new MultiValueMap(map, new ReflectionFactory(collectionClass)); } @@ -106,7 +107,8 @@ public class MultiValueMap extends AbstractMapDecorator impleme * @param map the map to decorate * @param collectionFactory the collection factory (must return a Collection object). */ - public static > MultiValueMap multiValueMap(Map map, Factory collectionFactory) { + public static > MultiValueMap multiValueMap(Map map, + Factory collectionFactory) { return new MultiValueMap(map, collectionFactory); } diff --git a/src/main/java/org/apache/commons/collections/map/PredicatedMap.java b/src/main/java/org/apache/commons/collections/map/PredicatedMap.java index 57853ba1e..55dcf537f 100644 --- a/src/main/java/org/apache/commons/collections/map/PredicatedMap.java +++ b/src/main/java/org/apache/commons/collections/map/PredicatedMap.java @@ -75,7 +75,9 @@ public class PredicatedMap * @param valuePredicate the predicate to validate to values, null means no check * @throws IllegalArgumentException if the map is null */ - public static IterableMap predicatedMap(Map map, Predicate keyPredicate, Predicate valuePredicate) { + public static PredicatedMap predicatedMap(Map map, + Predicate keyPredicate, + Predicate valuePredicate) { return new PredicatedMap(map, keyPredicate, valuePredicate); } diff --git a/src/main/java/org/apache/commons/collections/map/PredicatedSortedMap.java b/src/main/java/org/apache/commons/collections/map/PredicatedSortedMap.java index fe3418e5c..a3f2fbff8 100644 --- a/src/main/java/org/apache/commons/collections/map/PredicatedSortedMap.java +++ b/src/main/java/org/apache/commons/collections/map/PredicatedSortedMap.java @@ -62,7 +62,7 @@ public class PredicatedSortedMap extends PredicatedMap implements So * @param valuePredicate the predicate to validate to values, null means no check * @throws IllegalArgumentException if the map is null */ - public static SortedMap predicatedSortedMap(SortedMap map, + public static PredicatedSortedMap predicatedSortedMap(SortedMap map, Predicate keyPredicate, Predicate valuePredicate) { return new PredicatedSortedMap(map, keyPredicate, valuePredicate); } diff --git a/src/main/java/org/apache/commons/collections/map/TransformedMap.java b/src/main/java/org/apache/commons/collections/map/TransformedMap.java index 8128a73ef..8ad79b67a 100644 --- a/src/main/java/org/apache/commons/collections/map/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections/map/TransformedMap.java @@ -72,7 +72,7 @@ public class TransformedMap * @param valueTransformer the transformer to use for value conversion, null means no transformation * @throws IllegalArgumentException if map is null */ - public static IterableMap transformingMap(Map map, + public static TransformedMap transformingMap(Map map, Transformer keyTransformer, Transformer valueTransformer) { return new TransformedMap(map, keyTransformer, valueTransformer); @@ -92,7 +92,7 @@ public class TransformedMap * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ - public static Map transformedMap(Map map, + public static TransformedMap transformedMap(Map map, Transformer keyTransformer, Transformer valueTransformer) { TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer); diff --git a/src/main/java/org/apache/commons/collections/map/TransformedSortedMap.java b/src/main/java/org/apache/commons/collections/map/TransformedSortedMap.java index f52ffb94f..adc9c9ab0 100644 --- a/src/main/java/org/apache/commons/collections/map/TransformedSortedMap.java +++ b/src/main/java/org/apache/commons/collections/map/TransformedSortedMap.java @@ -62,7 +62,7 @@ public class TransformedSortedMap * @param valueTransformer the predicate to validate to values, null means no transformation * @throws IllegalArgumentException if the map is null */ - public static SortedMap transformingSortedMap(SortedMap map, + public static TransformedSortedMap transformingSortedMap(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { return new TransformedSortedMap(map, keyTransformer, valueTransformer); @@ -82,7 +82,7 @@ public class TransformedSortedMap * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ - public static SortedMap transformedSortedMap(SortedMap map, + public static TransformedSortedMap transformedSortedMap(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { TransformedSortedMap decorated = new TransformedSortedMap(map, keyTransformer, valueTransformer);