]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/RunnableWithObject.java b/bundles/org.simantics.utils/src/org/simantics/utils/RunnableWithObject.java
new file mode 100644 (file)
index 0000000..3c00b21
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.utils;\r
+\r
+/**\r
+ * This class is intended to be used as anonymous \r
+ * inner class\r
+ * \r
+ * \r
+ * @author Toni Kalajainen\r
+ */\r
+public class RunnableWithObject implements Runnable {\r
+\r
+    protected Object object, object2;\r
+    \r
+    protected Object objs[];\r
+    \r
+    public RunnableWithObject(Object o) {\r
+        object = o;\r
+        objs = new Object[] {o};\r
+    }\r
+\r
+    public RunnableWithObject(Object o, Object o2) {\r
+        object = o;\r
+        object2 = o2;\r
+        objs = new Object[] {o, o2};\r
+    }\r
+\r
+    public RunnableWithObject(Object... objs) {\r
+        this.objs = objs;\r
+        if (objs.length>=1)\r
+            object = objs[0];\r
+        if (objs.length>=2)\r
+            object2 = objs[1];\r
+    }\r
+    \r
+    public void run() {\r
+    }\r
+    \r
+    public Object getObject() {\r
+        return object;\r
+    }\r
+    \r
+    public int count() {\r
+        return objs.length;\r
+    }\r
+    \r
+    public Object getObject(int index) {\r
+        return objs[index];\r
+    }\r
+\r
+}\r