]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/RunnableWithObject.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / RunnableWithObject.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.utils;\r
13 \r
14 /**\r
15  * This class is intended to be used as anonymous \r
16  * inner class\r
17  * \r
18  * \r
19  * @author Toni Kalajainen\r
20  */\r
21 public class RunnableWithObject implements Runnable {\r
22 \r
23     protected Object object, object2;\r
24     \r
25     protected Object objs[];\r
26     \r
27     public RunnableWithObject(Object o) {\r
28         object = o;\r
29         objs = new Object[] {o};\r
30     }\r
31 \r
32     public RunnableWithObject(Object o, Object o2) {\r
33         object = o;\r
34         object2 = o2;\r
35         objs = new Object[] {o, o2};\r
36     }\r
37 \r
38     public RunnableWithObject(Object... objs) {\r
39         this.objs = objs;\r
40         if (objs.length>=1)\r
41             object = objs[0];\r
42         if (objs.length>=2)\r
43             object2 = objs[1];\r
44     }\r
45     \r
46     public void run() {\r
47     }\r
48     \r
49     public Object getObject() {\r
50         return object;\r
51     }\r
52     \r
53     public int count() {\r
54         return objs.length;\r
55     }\r
56     \r
57     public Object getObject(int index) {\r
58         return objs[index];\r
59     }\r
60 \r
61 }\r