]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ImmutableCollection.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / ImmutableCollection.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.datastructures;\r
13 \r
14 import java.util.Collection;\r
15 import java.util.Iterator;\r
16 \r
17 public abstract class ImmutableCollection<T> implements Collection<T> {\r
18 \r
19         public boolean add(T e) {\r
20                 throw new UnsupportedOperationException();\r
21         }\r
22 \r
23         public boolean addAll(Collection<? extends T> c) {\r
24                 throw new UnsupportedOperationException();\r
25         }\r
26 \r
27         public void clear() {\r
28                 throw new UnsupportedOperationException();\r
29         }\r
30 \r
31         public boolean remove(Object o) {\r
32                 throw new UnsupportedOperationException();\r
33         }\r
34 \r
35         public boolean removeAll(Collection<?> c) {\r
36                 throw new UnsupportedOperationException();\r
37         }\r
38 \r
39         public boolean retainAll(Collection<?> c) {\r
40                 throw new UnsupportedOperationException();\r
41         }\r
42 \r
43         abstract public boolean contains(Object o);\r
44         abstract public boolean containsAll(Collection<?> c);\r
45         abstract public boolean isEmpty();\r
46         abstract public Iterator<T> iterator();         \r
47         abstract public int size();\r
48         \r
49         public Object[] toArray() {\r
50                 Object[] ret = new Object[size()];\r
51                 int i=0;\r
52                 for(T a : this) \r
53                         ret[i++] = a;\r
54                 return ret;\r
55         }\r
56 \r
57         public <U> U[] toArray(U[] a) {\r
58                 // TODO\r
59                 throw new UnsupportedOperationException();\r
60         }\r
61         \r
62 }\r