X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FNewStatementImpl.java;h=518be61d42e73a2467f1a2835e507b61088dbaf5;hp=b4ff7c34de1219b23db25381fe3d7c8816adc53e;hb=HEAD;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java index b4ff7c34d..518be61d4 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java @@ -1,82 +1,82 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package fi.vtt.simantics.procore.internal; - -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.impl.ResourceImpl; - -public class NewStatementImpl implements Statement { - - public final ResourceImpl subject; - public final ResourceImpl predicate; - public final ResourceImpl object; - - public NewStatementImpl(int id, ResourceImpl subject, ResourceImpl predicate, ResourceImpl object) { - if (null == subject) - throw new IllegalArgumentException(); - if(null == predicate) - throw new IllegalArgumentException(); - if(null == predicate) - throw new IllegalArgumentException(); - this.subject = (ResourceImpl)subject; - this.predicate = (ResourceImpl)predicate; - this.object = (ResourceImpl)object; - } - @Override - final public Resource getObject() { - return object; - } - - @Override - final public Resource getPredicate() { - return predicate; - } - - @Override - final public Resource getSubject() { - return subject; - } - - public int hashCode() - { - // TODO: :) - int result = 6151 * ((int)(subject.id ^ (subject.id>>>32))*6151 + - (int)(predicate.id ^ (predicate.id>>>32))) + - (int)(object.id ^ (object.id>>>32)); - return result; - - } - - @Override - public boolean isAsserted(Resource testSubject) { - return !subject.equals(testSubject); - } - - public boolean equals(Object object) - { - if (this == object) - return true; - else if (object == null) - return false; - try { - Statement r = (Statement)object; - return subject.id == r.getSubject().getResourceId() && - predicate.id == r.getPredicate().getResourceId() && - this.object.id == r.getObject().getResourceId(); - } catch (ClassCastException e) { - return false; - } - } - - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package fi.vtt.simantics.procore.internal; + +import org.simantics.db.Resource; +import org.simantics.db.Statement; +import org.simantics.db.impl.ResourceImpl; + +public class NewStatementImpl implements Statement { + + public final ResourceImpl subject; + public final ResourceImpl predicate; + public final ResourceImpl object; + + public NewStatementImpl(int id, ResourceImpl subject, ResourceImpl predicate, ResourceImpl object) { + if (null == subject) + throw new IllegalArgumentException(); + if(null == predicate) + throw new IllegalArgumentException(); + if(null == object) + throw new IllegalArgumentException(); + this.subject = (ResourceImpl)subject; + this.predicate = (ResourceImpl)predicate; + this.object = (ResourceImpl)object; + } + @Override + final public Resource getObject() { + return object; + } + + @Override + final public Resource getPredicate() { + return predicate; + } + + @Override + final public Resource getSubject() { + return subject; + } + + public int hashCode() + { + // TODO: :) + int result = 6151 * ((int)(subject.id ^ (subject.id>>>32))*6151 + + (int)(predicate.id ^ (predicate.id>>>32))) + + (int)(object.id ^ (object.id>>>32)); + return result; + + } + + @Override + public boolean isAsserted(Resource testSubject) { + return !subject.equals(testSubject); + } + + public boolean equals(Object object) + { + if (this == object) + return true; + else if (object == null) + return false; + try { + Statement r = (Statement)object; + return subject.id == r.getSubject().getResourceId() && + predicate.id == r.getPredicate().getResourceId() && + this.object.id == r.getObject().getResourceId(); + } catch (ClassCastException e) { + return false; + } + } + + +}