org.opentripplanner.netex.loader.util.HierarchicalMultimap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.netex.loader.util;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
*
* A concrete multimap implementation of {@link AbstractHierarchicalMap}.
*
*
* Note that the collection retuned by the {@link ReadOnlyHierarchicalMap#lookup(Object)} is
* not ReadOnly, but should be treated as such. It is just to painful to achieve this with the
* current verion of the Java Collection API - without any side-effects.
*
* @param the key type
* @param the base value type
*/
public class HierarchicalMultimap extends AbstractHierarchicalMap> {
private Multimap map = ArrayListMultimap.create();
/** Create a root for the hierarchy */
public HierarchicalMultimap() {
super(null);
}
/** Create a child of the given {@code parent}. */
public HierarchicalMultimap(HierarchicalMultimap parent) {
super(parent);
}
/** Add a new pair of {@code key & value} to the local map value collection. */
public void add(K key, V value) {
map.put(key, value);
}
/** Add a multimap to the local map */
public void addAll(Multimap other) {
for (Map.Entry it : other.entries()) {
add(it.getKey(), it.getValue());
}
}
Collection localKeys() {
return map.keySet();
}
@Override
Collection localGet(K key) {
return map.get(key);
}
@Override
boolean localContainsKey(K key) {
return map.containsKey(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy