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