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.structural2.modelingRules;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.common.request.SafeName;
\r
17 import org.simantics.db.exception.DatabaseException;
\r
19 public class CPTerminal implements IConnectionPoint {
\r
21 public final Resource component; // may be null for reference elements
\r
22 public final Resource relation;
\r
24 public CPTerminal(Resource component, Resource relation) {
\r
25 if (relation == null)
\r
26 throw new NullPointerException("null relation");
\r
27 this.component = component;
\r
28 this.relation = relation;
\r
32 public String toString(ReadGraph g) throws DatabaseException {
\r
33 return "CPTerminal(" +
\r
34 g.syncRequest(new SafeName(component)) + ", " +
\r
35 g.syncRequest(new SafeName(relation)) + ")";
\r
39 public int hashCode() {
\r
40 final int prime = 31;
\r
42 result = prime * result + (component == null ? 0 : component.hashCode());
\r
43 result = prime * result + relation.hashCode();
\r
48 public boolean equals(Object obj) {
\r
53 if (getClass() != obj.getClass())
\r
55 CPTerminal other = (CPTerminal) obj;
\r
56 return (component == null ? other.component == null : component.equals(other.component)) && relation.equals(other.relation);
\r