fr.vergne.collection.impl.HashMultiMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of collection-core Show documentation
Show all versions of collection-core Show documentation
Implementation of the collection facilities.
package fr.vergne.collection.impl;
import java.util.Collection;
import java.util.HashSet;
import fr.vergne.collection.MultiMap;
/**
* A {@link HashMultiMap} is a {@link MultiMap} which allows at most one
* instance for each (key, value). If the same value is assigned several times
* to the same key, it is the same than providing it only once, and removing it
* once is enough to not have it anymore in the map.
*
* @author Matthieu Vergne
*
* @param
* @param
*/
@SuppressWarnings("serial")
public class HashMultiMap extends AbstractMultiMap
implements MultiMap {
public HashMultiMap(MultiMap map) {
for (Entry> entry : map.entrySet()) {
populate(entry.getKey(), entry.getValue());
}
}
public HashMultiMap() {
}
@Override
protected Collection generateInnerCollection(Key key) {
return new HashSet();
}
}