1 package org.simantics.structural2.queries;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.utils.NameUtils;
6 import org.simantics.db.exception.DatabaseException;
9 * @author Tuukka Lehtonen
11 public class Terminal {
13 private final Resource component;
14 private final Resource relation;
16 private final int hash;
18 public Terminal(Resource component, Resource relation) {
19 this.component = component;
20 this.relation = relation;
21 this.hash = makeHash();
25 public boolean equals(Object obj) {
30 if (!(obj.getClass().equals(this.getClass())))
32 Terminal other = (Terminal) obj;
33 return component.equals(other.component) && relation.equals(other.relation);
36 public Resource getComponent() {
40 public Resource getRelation() {
44 private int makeHash() {
45 return component.hashCode() + relation.hashCode() * 31;
49 public int hashCode() {
54 public String toString() {
55 return component + " " + relation;
58 public String toString(ReadGraph graph) throws DatabaseException {
59 return NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, relation);