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 fi.vtt.simantics.procore.internal;
\r
14 import org.simantics.db.Resource;
\r
15 import org.simantics.db.Statement;
\r
16 import org.simantics.db.impl.ResourceImpl;
\r
18 public class NewStatementImpl implements Statement {
\r
20 public final ResourceImpl subject;
\r
21 public final ResourceImpl predicate;
\r
22 public final ResourceImpl object;
\r
24 public NewStatementImpl(int id, ResourceImpl subject, ResourceImpl predicate, ResourceImpl object) {
\r
25 if (null == subject)
\r
26 throw new IllegalArgumentException();
\r
27 if(null == predicate)
\r
28 throw new IllegalArgumentException();
\r
29 if(null == predicate)
\r
30 throw new IllegalArgumentException();
\r
31 this.subject = (ResourceImpl)subject;
\r
32 this.predicate = (ResourceImpl)predicate;
\r
33 this.object = (ResourceImpl)object;
\r
36 final public Resource getObject() {
\r
41 final public Resource getPredicate() {
\r
46 final public Resource getSubject() {
\r
50 public int hashCode()
\r
53 int result = 6151 * ((int)(subject.id ^ (subject.id>>>32))*6151 +
\r
54 (int)(predicate.id ^ (predicate.id>>>32))) +
\r
55 (int)(object.id ^ (object.id>>>32));
\r
61 public boolean isAsserted(Resource testSubject) {
\r
62 return !subject.equals(testSubject);
\r
65 public boolean equals(Object object)
\r
69 else if (object == null)
\r
72 Statement r = (Statement)object;
\r
73 return subject.id == r.getSubject().getResourceId() &&
\r
74 predicate.id == r.getPredicate().getResourceId() &&
\r
75 this.object.id == r.getObject().getResourceId();
\r
76 } catch (ClassCastException e) {
\r