[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
This commit is contained in:
parent
36509cf59b
commit
902ee25dcf
|
@ -82,7 +82,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
|||
* @param defaultValue the default value to return when the key is not found
|
||||
* @throws IllegalArgumentException if map is null
|
||||
*/
|
||||
public static <K, V> Map<K, V> defaultedMap(Map<K, V> map, V defaultValue) {
|
||||
public static <K, V> DefaultedMap<K, V> defaultedMap(Map<K, V> map, V defaultValue) {
|
||||
return new DefaultedMap<K, V>(map, ConstantTransformer.constantTransformer(defaultValue));
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> 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 <K, V> IterableMap<K, V> defaultedMap(Map<K, V> map, Factory<? extends V> factory) {
|
||||
public static <K, V> DefaultedMap<K, V> defaultedMap(Map<K, V> map, Factory<? extends V> factory) {
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Factory must not be null");
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class FixedSizeMap<K, V>
|
|||
* @param map the map to decorate, must not be null
|
||||
* @throws IllegalArgumentException if map is null
|
||||
*/
|
||||
public static <K, V> IterableMap<K, V> fixedSizeMap(Map<K, V> map) {
|
||||
public static <K, V> FixedSizeMap<K, V> fixedSizeMap(Map<K, V> map) {
|
||||
return new FixedSizeMap<K, V>(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class FixedSizeSortedMap<K, V>
|
|||
* @param map the map to decorate, must not be null
|
||||
* @throws IllegalArgumentException if map is null
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> fixedSizeSortedMap(SortedMap<K, V> map) {
|
||||
public static <K, V> FixedSizeSortedMap<K, V> fixedSizeSortedMap(SortedMap<K, V> map) {
|
||||
return new FixedSizeSortedMap<K, V>(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class LazySortedMap<K,V>
|
|||
* @param factory the factory to use, must not be null
|
||||
* @throws IllegalArgumentException if map or factory is null
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map, Factory<? extends V> factory) {
|
||||
public static <K, V> LazySortedMap<K, V> lazySortedMap(SortedMap<K, V> map, Factory<? extends V> factory) {
|
||||
return new LazySortedMap<K,V>(map, factory);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ public class LazySortedMap<K,V>
|
|||
* @param factory the factory to use, must not be null
|
||||
* @throws IllegalArgumentException if map or factory is null
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map, Transformer<? super K, ? extends V> factory) {
|
||||
public static <K, V> LazySortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
|
||||
Transformer<? super K, ? extends V> factory) {
|
||||
return new LazySortedMap<K,V>(map, factory);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ListOrderedMap<K, V>
|
|||
* @param map the map to decorate, must not be null
|
||||
* @throws IllegalArgumentException if map is null
|
||||
*/
|
||||
public static <K, V> OrderedMap<K, V> listOrderedMap(Map<K, V> map) {
|
||||
public static <K, V> ListOrderedMap<K, V> listOrderedMap(Map<K, V> map) {
|
||||
return new ListOrderedMap<K, V>(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,8 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
* @param map the map to wrap
|
||||
* @param collectionClass the type of the collection class
|
||||
*/
|
||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, ? super C> map, Class<C> collectionClass) {
|
||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, ? super C> map,
|
||||
Class<C> collectionClass) {
|
||||
return new MultiValueMap<K, V>(map, new ReflectionFactory<C>(collectionClass));
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,8 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
* @param map the map to decorate
|
||||
* @param collectionFactory the collection factory (must return a Collection object).
|
||||
*/
|
||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, ? super C> map, Factory<C> collectionFactory) {
|
||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, ? super C> map,
|
||||
Factory<C> collectionFactory) {
|
||||
return new MultiValueMap<K, V>(map, collectionFactory);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,9 @@ public class PredicatedMap<K, V>
|
|||
* @param valuePredicate the predicate to validate to values, null means no check
|
||||
* @throws IllegalArgumentException if the map is null
|
||||
*/
|
||||
public static <K, V> IterableMap<K, V> predicatedMap(Map<K, V> map, Predicate<? super K> keyPredicate, Predicate<? super V> valuePredicate) {
|
||||
public static <K, V> PredicatedMap<K, V> predicatedMap(Map<K, V> map,
|
||||
Predicate<? super K> keyPredicate,
|
||||
Predicate<? super V> valuePredicate) {
|
||||
return new PredicatedMap<K, V>(map, keyPredicate, valuePredicate);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PredicatedSortedMap<K, V> extends PredicatedMap<K, V> implements So
|
|||
* @param valuePredicate the predicate to validate to values, null means no check
|
||||
* @throws IllegalArgumentException if the map is null
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> predicatedSortedMap(SortedMap<K, V> map,
|
||||
public static <K, V> PredicatedSortedMap<K, V> predicatedSortedMap(SortedMap<K, V> map,
|
||||
Predicate<? super K> keyPredicate, Predicate<? super V> valuePredicate) {
|
||||
return new PredicatedSortedMap<K, V>(map, keyPredicate, valuePredicate);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TransformedMap<K, V>
|
|||
* @param valueTransformer the transformer to use for value conversion, null means no transformation
|
||||
* @throws IllegalArgumentException if map is null
|
||||
*/
|
||||
public static <K, V> IterableMap<K, V> transformingMap(Map<K, V> map,
|
||||
public static <K, V> TransformedMap<K, V> transformingMap(Map<K, V> map,
|
||||
Transformer<? super K, ? extends K> keyTransformer,
|
||||
Transformer<? super V, ? extends V> valueTransformer) {
|
||||
return new TransformedMap<K, V>(map, keyTransformer, valueTransformer);
|
||||
|
@ -92,7 +92,7 @@ public class TransformedMap<K, V>
|
|||
* @throws IllegalArgumentException if map is null
|
||||
* @since Commons Collections 3.2
|
||||
*/
|
||||
public static <K, V> Map<K, V> transformedMap(Map<K, V> map,
|
||||
public static <K, V> TransformedMap<K, V> transformedMap(Map<K, V> map,
|
||||
Transformer<? super K, ? extends K> keyTransformer,
|
||||
Transformer<? super V, ? extends V> valueTransformer) {
|
||||
TransformedMap<K, V> decorated = new TransformedMap<K, V>(map, keyTransformer, valueTransformer);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TransformedSortedMap<K, V>
|
|||
* @param valueTransformer the predicate to validate to values, null means no transformation
|
||||
* @throws IllegalArgumentException if the map is null
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> transformingSortedMap(SortedMap<K, V> map,
|
||||
public static <K, V> TransformedSortedMap<K, V> transformingSortedMap(SortedMap<K, V> map,
|
||||
Transformer<? super K, ? extends K> keyTransformer,
|
||||
Transformer<? super V, ? extends V> valueTransformer) {
|
||||
return new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
|
||||
|
@ -82,7 +82,7 @@ public class TransformedSortedMap<K, V>
|
|||
* @throws IllegalArgumentException if map is null
|
||||
* @since Commons Collections 3.2
|
||||
*/
|
||||
public static <K, V> SortedMap<K, V> transformedSortedMap(SortedMap<K, V> map,
|
||||
public static <K, V> TransformedSortedMap<K, V> transformedSortedMap(SortedMap<K, V> map,
|
||||
Transformer<? super K, ? extends K> keyTransformer,
|
||||
Transformer<? super V, ? extends V> valueTransformer) {
|
||||
TransformedSortedMap<K, V> decorated = new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
|
||||
|
|
Loading…
Reference in New Issue