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.Set;
26
27
28
29
30
31 public final class ImmutableSet<T> implements Set<T> {
32
33
34
35 private Set<? extends T> set;
36
37
38
39
40 public ImmutableSet(final Set<? extends T> set) {
41 super();
42 this.set = set;
43 }
44
45
46
47
48 public boolean containsAll(final Collection<?> c) {
49 return this.set.containsAll(c);
50 }
51
52
53
54
55 public boolean contains(final Object o) {
56 return this.set.contains(o);
57 }
58
59
60
61
62 @Override
63 public boolean equals(final Object o) {
64 return this.set.equals(o);
65 }
66
67
68
69
70 @Override
71 public int hashCode() {
72 return this.set.hashCode();
73 }
74
75
76
77
78 public boolean isEmpty() {
79 return this.set.isEmpty();
80 }
81
82
83
84
85 public int size() {
86 return this.set.size();
87 }
88
89
90
91
92 public <K> K[] toArray(final K[] a) {
93 return this.set.toArray(a);
94 }
95
96
97
98
99 public Object[] toArray() {
100 return this.set.toArray();
101 }
102
103
104
105
106 public Iterator<T> iterator() {
107 return new ImmutableIterator<T>(this.set.iterator());
108 }
109
110
111
112
113 public boolean add(final T o) {
114 throw new UnsupportedOperationException("ImmutableSet.add");
115 }
116
117
118
119
120 public boolean remove(final Object o) {
121 throw new UnsupportedOperationException("ImmutableSet.remove");
122 }
123
124
125
126
127 public boolean addAll(final Collection<? extends T> c) {
128 throw new UnsupportedOperationException("ImmutableSet.addAll");
129 }
130
131
132
133
134 public boolean retainAll(final Collection<?> c) {
135 throw new UnsupportedOperationException("ImmutableSet.retainAll");
136 }
137
138
139
140
141 public boolean removeAll(final Collection<?> c) {
142 throw new UnsupportedOperationException("ImmutableSet.removeAll");
143 }
144
145
146
147
148 public void clear() {
149 throw new UnsupportedOperationException("ImmutableSet.clear");
150 }
151
152 }