]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/RelationContextImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / RelationContextImpl.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.impl;\r
13 \r
14 import org.simantics.db.RelationContext;\r
15 import org.simantics.db.Resource;\r
16 import org.simantics.db.Statement;\r
17 \r
18 final public class RelationContextImpl implements RelationContext {\r
19 \r
20     final private Resource subject;\r
21     final private Statement statement;\r
22 \r
23     public RelationContextImpl(Resource subject, Statement statement) {\r
24         assert(subject != null);\r
25         assert(statement != null);\r
26         this.subject = subject;\r
27         this.statement = statement;\r
28     }\r
29 \r
30     @Override\r
31     public int hashCode() {\r
32         return subject.hashCode() + 31 * statement.hashCode();\r
33     }\r
34     \r
35     @Override\r
36     public boolean equals(Object object) {\r
37         if (this == object)\r
38             return true;\r
39         else if (object == null)\r
40             return false;\r
41         else if (RelationContextImpl.class != object.getClass())\r
42             return false;\r
43         RelationContextImpl r = (RelationContextImpl)object;\r
44         return subject.equals(r.subject) && statement.equals(r.statement);\r
45     }\r
46 \r
47         @Override\r
48         public Resource getSubject() {\r
49                 return subject;\r
50         }\r
51 \r
52         @Override\r
53         public Statement getStatement() {\r
54                 return statement;\r
55         }\r
56 \r
57 }\r