| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.core.simple.cache; |
| |
| import java.util.Collection; |
| import java.util.Iterator; |
| |
| import org.eclipse.viatra2.core.IModelElement; |
| import org.eclipse.viatra2.core.simple.SimpleEntity; |
| |
| public class TrickyCollection implements Collection<IModelElement> { |
| |
| private SimpleEntity owner; |
| |
| private Collection<IModelElement> col; |
| |
| public TrickyCollection(Collection<IModelElement> c, SimpleEntity o) { |
| col = c; |
| owner = o; |
| } |
| |
| public boolean add(IModelElement arg0) { |
| return false; |
| } |
| |
| public boolean addAll(Collection arg0) { |
| return false; |
| } |
| |
| public void clear() { |
| |
| } |
| |
| public boolean contains(Object arg0) { |
| IModelElement me = (IModelElement) arg0; |
| return me.isBelowNamespace(owner); |
| } |
| |
| public boolean containsAll(Collection arg0) { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.containsAll(arg0); |
| } |
| |
| public boolean isEmpty() { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.isEmpty(); |
| } |
| |
| public Iterator<IModelElement> iterator() { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.iterator(); |
| } |
| |
| public boolean remove(Object arg0) { |
| return false; |
| } |
| |
| public boolean removeAll(Collection arg0) { |
| return false; |
| } |
| |
| public boolean retainAll(Collection arg0) { |
| return false; |
| } |
| |
| public int size() { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.size(); |
| } |
| |
| public Object[] toArray() { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.toArray(); |
| } |
| |
| public Object[] toArray(Object[] arg0) { |
| if (col == null) { |
| col = owner._getAllComponents(); |
| } |
| return col.toArray(arg0); |
| } |
| |
| } |