]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph/src/org/simantics/graph/store/IdRes.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / store / IdRes.java
diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/store/IdRes.java b/bundles/org.simantics.graph/src/org/simantics/graph/store/IdRes.java
new file mode 100644 (file)
index 0000000..4c099d1
--- /dev/null
@@ -0,0 +1,39 @@
+package org.simantics.graph.store;\r
+\r
+import org.simantics.graph.query.Res;\r
+\r
+/**\r
+ * A resource that exists only in one graph fragment. The resource\r
+ * is represented as a integer identifier.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class IdRes implements Res {\r
+       public final GraphStore fragment;\r
+       public final int id;\r
+       \r
+       public IdRes(GraphStore fragment, int id) {     \r
+               this.fragment = fragment;\r
+               this.id = id;\r
+       }\r
+\r
+       @Override\r
+       public int hashCode() {\r
+               return id * 31 + fragment.hashCode();\r
+       }\r
+\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               if (this == obj)\r
+                       return true;\r
+               if (obj == null || getClass() != obj.getClass())\r
+                       return false;\r
+               IdRes other = (IdRes) obj;\r
+               return fragment == other.fragment && id == other.id;\r
+       }       \r
+       \r
+       @Override\r
+       public String toString() {\r
+               return "#" + id;\r
+       }\r
+               \r
+}\r