X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fqueries%2FTerminal.java;h=519c10f121f72bf6a49fd5d5ad3ceb85e682775b;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=38e7f18d949c25ca8b0afe554e09693eb83a0cee;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/Terminal.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/Terminal.java index 38e7f18d9..519c10f12 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/Terminal.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/Terminal.java @@ -1,62 +1,62 @@ -package org.simantics.structural2.queries; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; - -/** - * @author Tuukka Lehtonen - */ -public class Terminal { - - private final Resource component; - private final Resource relation; - - private final int hash; - - public Terminal(Resource component, Resource relation) { - this.component = component; - this.relation = relation; - this.hash = makeHash(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj.getClass().equals(this.getClass()))) - return false; - Terminal other = (Terminal) obj; - return component.equals(other.component) && relation.equals(other.relation); - } - - public Resource getComponent() { - return component; - } - - public Resource getRelation() { - return relation; - } - - private int makeHash() { - return component.hashCode() + relation.hashCode() * 31; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public String toString() { - return component + " " + relation; - } - - public String toString(ReadGraph graph) throws DatabaseException { - return NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, relation); - } - -} +package org.simantics.structural2.queries; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; + +/** + * @author Tuukka Lehtonen + */ +public class Terminal { + + private final Resource component; + private final Resource relation; + + private final int hash; + + public Terminal(Resource component, Resource relation) { + this.component = component; + this.relation = relation; + this.hash = makeHash(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj.getClass().equals(this.getClass()))) + return false; + Terminal other = (Terminal) obj; + return component.equals(other.component) && relation.equals(other.relation); + } + + public Resource getComponent() { + return component; + } + + public Resource getRelation() { + return relation; + } + + private int makeHash() { + return component.hashCode() + relation.hashCode() * 31; + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public String toString() { + return component + " " + relation; + } + + public String toString(ReadGraph graph) throws DatabaseException { + return NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, relation); + } + +}