1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.webmancer.util.immutable;
22
23 import java.util.Collection;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.ListIterator;
27
28
29
30
31
32 public final class ImmutableList<T> implements List<T> {
33 private List<? extends T> list;
34
35
36
37
38 public ImmutableList(final List<? extends T> list) {
39 super();
40 this.list = list;
41 }
42
43
44
45
46 public boolean containsAll(final Collection<?> c) {
47 return this.list.containsAll(c);
48 }
49
50
51
52
53 public boolean contains(final Object o) {
54 return this.list.contains(o);
55 }
56
57
58
59
60 @Override
61 public boolean equals(final Object o) {
62 return this.list.equals(o);
63 }
64
65
66
67
68 public T get(final int index) {
69 return this.list.get(index);
70 }
71
72
73
74
75 @Override
76 public int hashCode() {
77 return this.list.hashCode();
78 }
79
80
81
82
83 public int indexOf(final Object o) {
84 return this.list.indexOf(o);
85 }
86
87
88
89
90 public boolean isEmpty() {
91 return this.list.isEmpty();
92 }
93
94
95
96
97 public int lastIndexOf(final Object o) {
98 return this.list.lastIndexOf(o);
99 }
100
101
102
103
104 public int size() {
105 return this.list.size();
106 }
107
108
109
110
111 public List<T> subList(final int fromIndex, final int toIndex) {
112 return new ImmutableList<T>(this.list.subList(fromIndex, toIndex));
113 }
114
115
116
117
118 public <K> K[] toArray(final K[] a) {
119 return this.list.toArray(a);
120 }
121
122
123
124
125 public Object[] toArray() {
126 return this.list.toArray();
127 }
128
129
130
131
132 public Iterator<T> iterator() {
133 return new ImmutableIterator<T>(this.list.iterator());
134 }
135
136
137
138
139 public boolean add(final T o) {
140 throw new UnsupportedOperationException("ImmutableList.add");
141 }
142
143
144
145
146 public boolean remove(final Object o) {
147 throw new UnsupportedOperationException("ImmutableList.remove");
148 }
149
150
151
152
153 public boolean addAll(final Collection<? extends T> c) {
154 throw new UnsupportedOperationException("ImmutableList.addAll");
155 }
156
157
158
159
160 public boolean addAll(final int index, final Collection<? extends T> c) {
161 throw new UnsupportedOperationException("ImmutableList.addAll");
162 }
163
164
165
166
167 public boolean removeAll(final Collection<?> c) {
168 throw new UnsupportedOperationException("ImmutableList.removeAll");
169 }
170
171
172
173
174 public boolean retainAll(final Collection<?> c) {
175 throw new UnsupportedOperationException("ImmutableList.retainAll");
176 }
177
178
179
180
181 public void clear() {
182 throw new UnsupportedOperationException("ImmutableList.clear");
183 }
184
185
186
187
188 public T set(final int index, final T element) {
189 throw new UnsupportedOperationException("ImmutableList.set");
190 }
191
192
193
194
195 public void add(final int index, final T element) {
196 throw new UnsupportedOperationException("ImmutableList.add");
197 }
198
199
200
201
202 public T remove(final int index) {
203 throw new UnsupportedOperationException("ImmutableList.remove");
204 }
205
206
207
208
209 public ListIterator<T> listIterator() {
210 return new ImmutableListIterator<T>(this.list.listIterator());
211 }
212
213
214
215
216 public ListIterator<T> listIterator(final int index) {
217 return new ImmutableListIterator<T>(this.list.listIterator(index));
218 }
219
220 }