]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/RunnableWithObject.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / RunnableWithObject.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.utils;
13
14 /**
15  * This class is intended to be used as anonymous 
16  * inner class
17  * 
18  * 
19  * @author Toni Kalajainen
20  */
21 public class RunnableWithObject implements Runnable {
22
23     protected Object object, object2;
24     
25     protected Object objs[];
26     
27     public RunnableWithObject(Object o) {
28         object = o;
29         objs = new Object[] {o};
30     }
31
32     public RunnableWithObject(Object o, Object o2) {
33         object = o;
34         object2 = o2;
35         objs = new Object[] {o, o2};
36     }
37
38     public RunnableWithObject(Object... objs) {
39         this.objs = objs;
40         if (objs.length>=1)
41             object = objs[0];
42         if (objs.length>=2)
43             object2 = objs[1];
44     }
45     
46     public void run() {
47     }
48     
49     public Object getObject() {
50         return object;
51     }
52     
53     public int count() {
54         return objs.length;
55     }
56     
57     public Object getObject(int index) {
58         return objs[index];
59     }
60
61 }