Add MultiValueMap providing control over the map and collection implementations

29440

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@171256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-05-21 21:12:54 +00:00
parent 9072508ad0
commit e6faf4b4a6
2 changed files with 46 additions and 44 deletions

View File

@ -42,6 +42,7 @@ If this causes major headaches to anyone please contact commons-dev at jakarta.a
<center><h3>NEW CLASSES</h3></center>
<ul>
<li>MultiValueMap - Decorator implementation of MultiMap providing control over the map and collection implementations [29440]</li>
<li>DefaultedMap - Returns a default value when the key is not found, without adding the default value to the map itself [30911]</li>
<li>GrowthList - Decorator that causes set and indexed add to expand the list rather than throw IndexOutOfBoundsException [34171]</li>
<li>LoopingListIterator - When the end of the list is reached the iteration continues from the start [30166]</li>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1377,7 +1377,50 @@ public class MapUtils {
public static Map orderedMap(Map map) {
return ListOrderedMap.decorate(map);
}
/**
* Creates a mult-value map backed by the given map which returns
* collections of type ArrayList.
*
* @param map the map to decorate
* @return a multi-value map backed by the given map which returns ArrayLists of values.
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap(Map map) {
return MultiValueMap.decorate(map);
}
/**
* Creates a multi-value map backed by the given map which returns
* collections of the specified type.
*
* @param map the map to decorate
* @param collectionClass the type of collections to return from the map (must contain public no-arg constructor
* and extend Collection).
* @return a multi-value map backed by the given map which returns collections of the specified type
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap(Map map, Class collectionClass) {
return MultiValueMap.decorate(map, collectionClass);
}
/**
* Creates a multi-value map backed by the given map which returns
* collections created by the specified collection factory.
*
* @param map the map to decorate
* @param collectionFactory a factor which creates collection objects
* @return a multi-value map backed by the given map which returns collections
* created by the specified collection factory
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap(Map map, Factory collectionFactory) {
return MultiValueMap.decorate(map, collectionFactory);
}
// SortedMap decorators
//-----------------------------------------------------------------------
/**
@ -1556,46 +1599,4 @@ public class MapUtils {
return LazySortedMap.decorate(map, transformerFactory);
}
/**
* Creates a mult-value map backed by the given map which returns ArrayLists.
* @param map the map to decorate
* @return a multi-value map backed by the given map which returns ArrayLists of values.
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap( Map map ) {
return MultiValueMap.decorate( map );
}
/**
* Creates a multi-value map backed by the given map which returns collections of
* the specified type.
* @param map the map to decorate
* @param collectionClass the type of collections to return from the map (must contain public no-arg constructor
* and extend Collection).
* @return a multi-value map backed by the given map which returns collections of the specified type
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap( Map map, Class collectionClass ) {
return MultiValueMap.decorate( map, collectionClass );
}
/**
* Creates a multi-value map backed by the given map which returns collections
* created by the specified collection factory.
* @param map the map to decorate
* @param collectionFactory a factor which creates collection objects
* @return a multi-value map backed by the given map which returns collections
* created by the specified collection factory
* @see MultiValueMap
* @since Commons Collections 3.2
*/
public static Map multiValueMap( Map map, Factory collectionFactory ) {
return MultiValueMap.decorate( map, collectionFactory );
}
}