]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectStatementImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / DirectStatementImpl.java
diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectStatementImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectStatementImpl.java
new file mode 100644 (file)
index 0000000..4a26dee
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.vtt.simantics.procore.internal;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Statement;\r
+import org.simantics.db.impl.ResourceImpl;\r
+import org.simantics.db.impl.support.ResourceSupport;\r
+\r
+final public class DirectStatementImpl implements Statement {\r
+\r
+       final ResourceSupport support;\r
+       final int s;\r
+       final int p;\r
+       final int o;\r
+       \r
+       DirectStatementImpl(ResourceSupport support, int s, int p, int o) {\r
+               this.support = support;\r
+               this.s = s;\r
+               this.p = p;\r
+               this.o = o;\r
+       }\r
+\r
+       @Override\r
+       public Resource getObject() {\r
+               return new ResourceImpl(support, o);\r
+       }\r
+\r
+       @Override\r
+       public Resource getPredicate() {\r
+               return new ResourceImpl(support, p);\r
+       }\r
+\r
+       @Override\r
+       public Resource getSubject() {\r
+               return new ResourceImpl(support, s);\r
+       }\r
+\r
+       @Override\r
+       public boolean isAsserted(Resource subject) {\r
+               return false;\r
+       }\r
+       \r
+    @Override\r
+    final public int hashCode() {\r
+        return 41 * ( 31 * s + p) + o;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object object) {\r
+        if (this == object)\r
+            return true;\r
+        else if (object == null)\r
+            return false;\r
+        else if (!(object instanceof Statement))\r
+            return false;\r
+        Statement r = (Statement)object;\r
+        return getSubject().equalsResource(r.getSubject()) && getPredicate().equalsResource(r.getPredicate()) && getObject().equalsResource(r.getObject());\r
+    }\r
+}\r