@@ -0,0 +1,1892 @@
+/*%0A *  Copyright 2011 Eric F. Savage, code@efsavage.com%0A *%0A *   Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *   you may not use this file except in compliance with the License.%0A *   You may obtain a copy of the License at%0A *%0A *       http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *   Unless required by applicable law or agreed to in writing, software%0A *   distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *   See the License for the specific language governing permissions and%0A *   limitations under the License.%0A */%0Apackage com.ajah.lang;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0A%0A/**%0A * Extension of %7B@link HashMap%7D that has a methods to make dealing with the%0A * value lists easier.%0A * %0A * @author %3Ca href=%22http://efsavage.com%22%3EEric F. Savage%3C/a%3E, %3Ca%0A *         href=%22mailto:code@efsavage.com%22%3Ecode@efsavage.com%3C/a%3E.%0A * %0A * @param %3CK%3E%0A * @param %3CV%3E%0A */%0Apublic class ListMap%3CK, V%3E extends HashMap%3CK, List%3CV%3E%3E %7B%0A%0A%09/**%0A%09 * Adds a value to the list for a given key, creating that list if%0A%09 * necessary.%0A%09 * %0A%09 * @param key%0A%09 *            The key to look up the value list.%0A%09 * @param value%0A%09 *            The value to add to the list.%0A%09 */%0A%09public void putValue(K key, V value) %7B%0A%09%09List%3CV%3E list = get(key);%0A%09%09if (list == null) %7B%0A%09%09%09list = new ArrayList%3CV%3E();%0A%09%09%09put(key, list);%0A%09%09%7D%0A%09%09list.add(value);%0A%09%7D%0A%0A%09/**%0A%09 * Returns the list found at the specified key or an empty list. Avoids%0A%09 * %7B@link NullPointerException%7D for iterators.%0A%09 * %0A%09 * @param key%0A%09 *            The key to look up the value list.%0A%09 * @return The value list, may be empty, will not be null.%0A%09 */%0A%09public List%3CV%3E getList(K key) %7B%0A%09%09List%3CV%3E list = get(key);%0A%09%09if (list == null) %7B%0A%09%09%09return Collections.emptyList();%0A%09%09%7D%0A%09%09return list;%0A%09%7D%0A%0A%7D%0A

Add ListMap class