]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ImmutableCollection.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / ImmutableCollection.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.datastructures;
13
14 import java.util.Collection;
15 import java.util.Iterator;
16
17 public abstract class ImmutableCollection<T> implements Collection<T> {
18
19         public boolean add(T e) {
20                 throw new UnsupportedOperationException();
21         }
22
23         public boolean addAll(Collection<? extends T> c) {
24                 throw new UnsupportedOperationException();
25         }
26
27         public void clear() {
28                 throw new UnsupportedOperationException();
29         }
30
31         public boolean remove(Object o) {
32                 throw new UnsupportedOperationException();
33         }
34
35         public boolean removeAll(Collection<?> c) {
36                 throw new UnsupportedOperationException();
37         }
38
39         public boolean retainAll(Collection<?> c) {
40                 throw new UnsupportedOperationException();
41         }
42
43         abstract public boolean contains(Object o);
44         abstract public boolean containsAll(Collection<?> c);
45         abstract public boolean isEmpty();
46         abstract public Iterator<T> iterator();         
47         abstract public int size();
48         
49         public Object[] toArray() {
50                 Object[] ret = new Object[size()];
51                 int i=0;
52                 for(T a : this) 
53                         ret[i++] = a;
54                 return ret;
55         }
56
57         public <U> U[] toArray(U[] a) {
58                 // TODO
59                 throw new UnsupportedOperationException();
60         }
61         
62 }