1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.element.handler.impl;
14 import java.util.Collection;
15 import java.util.HashMap;
18 import org.simantics.g2d.diagram.handler.Topology.Terminal;
19 import org.simantics.g2d.element.IElement;
20 import org.simantics.g2d.element.handler.TerminalData;
21 import org.simantics.utils.datastructures.hints.IHintContext.Key;
24 * TerminalDataImpl that is used in ElementClass
26 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
29 public class UniqueTerminalDataImpl implements TerminalData {
31 private static final long serialVersionUID = -2131030904280472077L;
33 private final Map<Terminal,Map<Key,Object>> terminals = new HashMap<Terminal, Map<Key,Object>>();
35 public UniqueTerminalDataImpl(Collection<? extends Terminal> terminals) {
36 for (Terminal t : terminals) {
37 this.terminals.put(t, new HashMap<Key, Object>(2));
44 public <T> T getHint(IElement e, Terminal t, Key key) {
45 Map<Key,Object> data = terminals.get(t);
47 return (T)data.get(key);
52 public void setHint(IElement e, Terminal t, Key key, Object value) {
53 Map<Key,Object> data = terminals.get(t);