]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph/src/org/simantics/graph/store/IdRes.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / store / IdRes.java
1 package org.simantics.graph.store;
2
3 import org.simantics.graph.query.Res;
4
5 /**
6  * A resource that exists only in one graph fragment. The resource
7  * is represented as a integer identifier.
8  * @author Hannu Niemistö
9  */
10 public class IdRes implements Res {
11         public final GraphStore fragment;
12         public final int id;
13         
14         public IdRes(GraphStore fragment, int id) {     
15                 this.fragment = fragment;
16                 this.id = id;
17         }
18
19         @Override
20         public int hashCode() {
21                 return id * 31 + fragment.hashCode();
22         }
23
24         @Override
25         public boolean equals(Object obj) {
26                 if (this == obj)
27                         return true;
28                 if (obj == null || getClass() != obj.getClass())
29                         return false;
30                 IdRes other = (IdRes) obj;
31                 return fragment == other.fragment && id == other.id;
32         }       
33         
34         @Override
35         public String toString() {
36                 return "#" + id;
37         }
38                 
39 }