All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.netex.loader.util.HierarchicalMultimap Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy