]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/request/SyncSetResourceRead.java
Automatically import also SCLMain modules of dependent index roots
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / SyncSetResourceRead.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.common.request;
13
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.procedure.AsyncProcedure;
17 import org.simantics.db.procedure.SyncSetListener;
18 import org.simantics.db.request.AsyncRead;
19
20 public abstract class SyncSetResourceRead<T> implements AsyncRead<Object>, SetListenerRead<T> {
21
22     final protected SyncSetListener<T> procedure;
23     final protected Resource resource;
24
25     @Override
26     public int hashCode() {
27         return resource.hashCode() + 31 * procedure.hashCode();
28     }
29     
30     @Override
31     public int threadHash() {
32         return resource.getThreadHash();
33     }
34     
35     @Override
36     public boolean equals(Object object) {
37         if (this == object)
38             return true;
39         else if (object == null)
40             return false;
41         else if (getClass() != object.getClass())
42             return false;
43         SyncSetResourceRead<?> r = (SyncSetResourceRead<?>) object;
44         return resource.equals(r.resource) && procedure.equals(r.procedure);
45     }
46
47     public SyncSetResourceRead(Resource resource, SyncSetListener<T> procedure) {
48         this.resource = resource;
49         this.procedure = procedure;
50     }
51
52     @Override
53     public void perform(AsyncReadGraph graph, AsyncProcedure<Object> dummy) {
54         execute(graph, procedure);
55         dummy.execute(graph, null);
56     }
57     
58 }