X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fstore%2FIdRes.java;fp=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fstore%2FIdRes.java;h=4c099d1428923a8c38df38afb268f88711a07223;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..4c099d142 --- /dev/null +++ b/bundles/org.simantics.graph/src/org/simantics/graph/store/IdRes.java @@ -0,0 +1,39 @@ +package org.simantics.graph.store; + +import org.simantics.graph.query.Res; + +/** + * A resource that exists only in one graph fragment. The resource + * is represented as a integer identifier. + * @author Hannu Niemistö + */ +public class IdRes implements Res { + public final GraphStore fragment; + public final int id; + + public IdRes(GraphStore fragment, int id) { + this.fragment = fragment; + this.id = id; + } + + @Override + public int hashCode() { + return id * 31 + fragment.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + IdRes other = (IdRes) obj; + return fragment == other.fragment && id == other.id; + } + + @Override + public String toString() { + return "#" + id; + } + +}