]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/CPConnection.java
IConnectionPoint and canBeConnected-checking util to SCL
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / modelingRules / CPConnection.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.structural2.modelingRules;
13
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16
17 public class CPConnection implements IConnectionPoint {
18
19     public final Resource connection;
20
21     public CPConnection(Resource connection) {
22         if (connection == null)
23             throw new NullPointerException("null connection");
24         this.connection = connection;
25     }
26
27     @Override
28     public String toString(ReadGraph g) {
29         return "CPConnection(" + (connection) + ")";
30     }
31
32     @Override
33     public int hashCode() {
34         return connection.hashCode();
35     }
36
37     @Override
38     public boolean equals(Object obj) {
39         if (this == obj)
40             return true;
41         if (obj == null)
42             return false;
43         if (getClass() != obj.getClass())
44             return false;
45         CPConnection other = (CPConnection) obj;
46         return connection.equals(other.connection);
47     }
48
49 }