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.connection;
14 import org.simantics.g2d.diagram.handler.Topology.Connection;
15 import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;
16 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
19 * @author Tuukka Lehtonen
21 public class EndKeyOf extends KeyOf {
23 private final EdgeEnd end;
26 private static final EndKeyOf BEGIN = new EndKeyOf(EdgeEnd.Begin, Connection.class);
27 private static final EndKeyOf END = new EndKeyOf(EdgeEnd.End, Connection.class);
28 public static final EndKeyOf[] KEYS = { BEGIN, END };
30 public static EndKeyOf get(EdgeEnd end) {
32 case Begin: return BEGIN;
34 default: throw new IllegalArgumentException("unrecognized EdgeEnd value: " + end);
38 private EndKeyOf(EdgeEnd end, Class<?> clazz) {
41 hash = end.hashCode();
44 public EdgeEnd getEnd() {
49 public int hashCode() {
54 public boolean equals(Object obj) {
55 if (!(obj instanceof EndKeyOf))
57 EndKeyOf other = (EndKeyOf) obj;
58 if (!other.end.equals(end)) return false;
63 public String toString() {
64 return getClass().getSimpleName() + "[" + end + "]";