1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.connection;
\r
14 import org.simantics.g2d.diagram.handler.Topology.Connection;
\r
15 import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;
\r
16 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
\r
19 * @author Tuukka Lehtonen
\r
21 public class EndKeyOf extends KeyOf {
\r
23 private final EdgeEnd end;
\r
26 private static final EndKeyOf BEGIN = new EndKeyOf(EdgeEnd.Begin, Connection.class);
\r
27 private static final EndKeyOf END = new EndKeyOf(EdgeEnd.End, Connection.class);
\r
28 public static final EndKeyOf[] KEYS = { BEGIN, END };
\r
30 public static EndKeyOf get(EdgeEnd end) {
\r
32 case Begin: return BEGIN;
\r
33 case End: return END;
\r
34 default: throw new IllegalArgumentException("unrecognized EdgeEnd value: " + end);
\r
38 private EndKeyOf(EdgeEnd end, Class<?> clazz) {
\r
41 hash = end.hashCode();
\r
44 public EdgeEnd getEnd() {
\r
49 public int hashCode() {
\r
54 public boolean equals(Object obj) {
\r
55 if (!(obj instanceof EndKeyOf))
\r
57 EndKeyOf other = (EndKeyOf) obj;
\r
58 if (!other.end.equals(end)) return false;
\r
63 public String toString() {
\r
64 return getClass().getSimpleName() + "[" + end + "]";
\r