package org.dynmap; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; public class ComponentManager { public Set components = new HashSet(); public Map> componentLookup = new HashMap>(); public void add(Component c) { if (components.add(c)) { String key = c.getClass().toString(); List clist = componentLookup.get(key); if (clist == null) { clist = new ArrayList(); componentLookup.put(key, clist); } clist.add(c); } } public void remove(Component c) { if (components.remove(c)) { String key = c.getClass().toString(); List clist = componentLookup.get(key); if (clist != null) { clist.remove(c); } } } public void clear() { componentLookup.clear(); components.clear(); } public Iterable getComponents(Class c) { List list = componentLookup.get(c.toString()); if (list == null) return new ArrayList(); return list; } }