--- /dev/null
+/*******************************************************************************\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.layer0.utils.instantiation;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Helper class for creating multi-instances.\r
+ * Note : This does NOT check conflicting requirements. \r
+ * \r
+ * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public class MultiInstance extends Instance {\r
+ \r
+ public MultiInstance(Collection<Instance> instances, Resource instanceOf) {\r
+ for (Instance i : instances) {\r
+ if (i.equals != null)\r
+ throw new UnsupportedOperationException("Don't know how to handle equal instances.");\r
+ for (RelatedInstance ri : i.relatedInstances) {\r
+ boolean contains = false;\r
+ for (RelatedInstance cri : relatedInstances) {\r
+ if (cri.relation == ri.relation &&\r
+ cri.relation != instanceOf) {\r
+ contains = true;\r
+ break;\r
+ }\r
+ }\r
+ if(!contains) {\r
+ relatedInstances.add(ri);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+}\r