--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.element.handler.impl;\r
+\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.g2d.diagram.handler.Topology.Terminal;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.TerminalData;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+/**\r
+ * TerminalDataImpl that is used in ElementClass\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public class UniqueTerminalDataImpl implements TerminalData {\r
+\r
+ private static final long serialVersionUID = -2131030904280472077L;\r
+\r
+ private final Map<Terminal,Map<Key,Object>> terminals = new HashMap<Terminal, Map<Key,Object>>();\r
+\r
+ public UniqueTerminalDataImpl(Collection<? extends Terminal> terminals) {\r
+ for (Terminal t : terminals) {\r
+ this.terminals.put(t, new HashMap<Key, Object>(2));\r
+ }\r
+ }\r
+\r
+\r
+\r
+ @Override\r
+ public <T> T getHint(IElement e, Terminal t, Key key) {\r
+ Map<Key,Object> data = terminals.get(t);\r
+ if (data != null)\r
+ return (T)data.get(key);\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void setHint(IElement e, Terminal t, Key key, Object value) {\r
+ Map<Key,Object> data = terminals.get(t);\r
+ data.put(key, value);\r
+ }\r
+\r
+}\r