ImmutableCollection.java
5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import javax.annotation.Nullable;
import nj;
import ph;
@GwtCompatible(emulated=true)
public abstract class ImmutableCollection<E>
extends AbstractCollection<E>
implements Serializable
{
private transient ImmutableList<E> a;
protected int a(Object[] paramArrayOfObject, int paramInt)
{
Iterator localIterator = iterator();
while (localIterator.hasNext())
{
paramArrayOfObject[paramInt] = localIterator.next();
paramInt += 1;
}
return paramInt;
}
public abstract boolean a();
@Deprecated
public final boolean add(E paramE)
{
throw new UnsupportedOperationException();
}
@Deprecated
public final boolean addAll(Collection<? extends E> paramCollection)
{
throw new UnsupportedOperationException();
}
public ImmutableList<E> asList()
{
ImmutableList localImmutableList2 = this.a;
ImmutableList localImmutableList1 = localImmutableList2;
if (localImmutableList2 == null)
{
localImmutableList1 = c();
this.a = localImmutableList1;
}
return localImmutableList1;
}
public ImmutableList<E> c()
{
switch (size())
{
default:
return new ph(this, toArray());
case 0:
return ImmutableList.of();
}
return ImmutableList.of(iterator().next());
}
@Deprecated
public final void clear()
{
throw new UnsupportedOperationException();
}
public boolean contains(@Nullable Object paramObject)
{
return (paramObject != null) && (super.contains(paramObject));
}
public abstract UnmodifiableIterator<E> iterator();
@Deprecated
public final boolean remove(Object paramObject)
{
throw new UnsupportedOperationException();
}
@Deprecated
public final boolean removeAll(Collection<?> paramCollection)
{
throw new UnsupportedOperationException();
}
@Deprecated
public final boolean retainAll(Collection<?> paramCollection)
{
throw new UnsupportedOperationException();
}
public final Object[] toArray()
{
int i = size();
if (i == 0) {
return ObjectArrays.a;
}
Object[] arrayOfObject = new Object[i];
a(arrayOfObject, 0);
return arrayOfObject;
}
public final <T> T[] toArray(T[] paramArrayOfT)
{
Preconditions.checkNotNull(paramArrayOfT);
int i = size();
Object localObject;
if (paramArrayOfT.length < i) {
localObject = ObjectArrays.newArray(paramArrayOfT, i);
}
for (;;)
{
a((Object[])localObject, 0);
return (T[])localObject;
localObject = paramArrayOfT;
if (paramArrayOfT.length > i)
{
paramArrayOfT[i] = null;
localObject = paramArrayOfT;
}
}
}
public Object writeReplace()
{
return new ImmutableList.b(toArray());
}
public static abstract class Builder<E>
{
static int a(int paramInt1, int paramInt2)
{
if (paramInt2 < 0) {
throw new AssertionError("cannot store more than MAX_VALUE elements");
}
int i = (paramInt1 >> 1) + paramInt1 + 1;
paramInt1 = i;
if (i < paramInt2) {
paramInt1 = Integer.highestOneBit(paramInt2 - 1) << 1;
}
paramInt2 = paramInt1;
if (paramInt1 < 0) {
paramInt2 = Integer.MAX_VALUE;
}
return paramInt2;
}
public abstract Builder<E> add(E paramE);
public Builder<E> add(E... paramVarArgs)
{
int j = paramVarArgs.length;
int i = 0;
while (i < j)
{
add(paramVarArgs[i]);
i += 1;
}
return this;
}
public Builder<E> addAll(Iterable<? extends E> paramIterable)
{
paramIterable = paramIterable.iterator();
while (paramIterable.hasNext()) {
add(paramIterable.next());
}
return this;
}
public Builder<E> addAll(Iterator<? extends E> paramIterator)
{
while (paramIterator.hasNext()) {
add(paramIterator.next());
}
return this;
}
public abstract ImmutableCollection<E> build();
}
static abstract class a<E>
extends ImmutableCollection.Builder<E>
{
Object[] a;
int b;
a(int paramInt)
{
nj.a(paramInt, "initialCapacity");
this.a = new Object[paramInt];
this.b = 0;
}
private void a(int paramInt)
{
if (this.a.length < paramInt) {
this.a = ObjectArrays.a(this.a, a(this.a.length, paramInt));
}
}
public ImmutableCollection.Builder<E> add(E... paramVarArgs)
{
ObjectArrays.a(paramVarArgs);
a(this.b + paramVarArgs.length);
System.arraycopy(paramVarArgs, 0, this.a, this.b, paramVarArgs.length);
this.b += paramVarArgs.length;
return this;
}
public a<E> add(E paramE)
{
Preconditions.checkNotNull(paramE);
a(this.b + 1);
Object[] arrayOfObject = this.a;
int i = this.b;
this.b = (i + 1);
arrayOfObject[i] = paramE;
return this;
}
public ImmutableCollection.Builder<E> addAll(Iterable<? extends E> paramIterable)
{
if ((paramIterable instanceof Collection))
{
Collection localCollection = (Collection)paramIterable;
int i = this.b;
a(localCollection.size() + i);
}
super.addAll(paramIterable);
return this;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/collect/ImmutableCollection.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/