]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/RelationContextImpl.java
Disabled BOOKKEEPING flag for normal use
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / RelationContextImpl.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.db.impl;
13
14 import org.simantics.db.RelationContext;
15 import org.simantics.db.Resource;
16 import org.simantics.db.Statement;
17
18 final public class RelationContextImpl implements RelationContext {
19
20     final private Resource subject;
21     final private Statement statement;
22
23     public RelationContextImpl(Resource subject, Statement statement) {
24         assert(subject != null);
25         assert(statement != null);
26         this.subject = subject;
27         this.statement = statement;
28     }
29
30     @Override
31     public int hashCode() {
32         return subject.hashCode() + 31 * statement.hashCode();
33     }
34     
35     @Override
36     public boolean equals(Object object) {
37         if (this == object)
38             return true;
39         else if (object == null)
40             return false;
41         else if (RelationContextImpl.class != object.getClass())
42             return false;
43         RelationContextImpl r = (RelationContextImpl)object;
44         return subject.equals(r.subject) && statement.equals(r.statement);
45     }
46
47         @Override
48         public Resource getSubject() {
49                 return subject;
50         }
51
52         @Override
53         public Statement getStatement() {
54                 return statement;
55         }
56
57 }