1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.layer0.utils.instantiation;
14 import java.util.Collection;
16 import org.simantics.db.Resource;
19 * Helper class for creating multi-instances.
20 * Note : This does NOT check conflicting requirements.
22 * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
25 public class MultiInstance extends Instance {
27 public MultiInstance(Collection<Instance> instances, Resource instanceOf) {
28 for (Instance i : instances) {
30 throw new UnsupportedOperationException("Don't know how to handle equal instances.");
31 for (RelatedInstance ri : i.relatedInstances) {
32 boolean contains = false;
33 for (RelatedInstance cri : relatedInstances) {
34 if (cri.relation == ri.relation &&
35 cri.relation != instanceOf) {
41 relatedInstances.add(ri);