~ubuntu-branches/ubuntu/wily/gs-collections/wily

« back to all changes in this revision

Viewing changes to gs-collections-code-generator/src/main/resources/impl/map/immutable/immutableObjectPrimitiveEmptyMap.stg

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2015-07-23 12:42:30 UTC
  • Revision ID: package-import@ubuntu.com-20150723124230-2rjvfv6elyn2m7d4
Tags: upstream-5.1.0
ImportĀ upstreamĀ versionĀ 5.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import "copyright.stg"
 
2
import "primitiveEquals.stg"
 
3
import "primitiveHashCode.stg"
 
4
import "primitiveLiteral.stg"
 
5
 
 
6
targetPath() ::= "com/gs/collections/impl/map/immutable/primitive"
 
7
 
 
8
fileName(primitive) ::= "ImmutableObject<primitive.name>EmptyMap"
 
9
 
 
10
class(primitive) ::= <<
 
11
<body(primitive.type, primitive.name)>
 
12
>>
 
13
 
 
14
body(type, name) ::= <<
 
15
<copyright()>
 
16
 
 
17
package com.gs.collections.impl.map.immutable.primitive;
 
18
 
 
19
import java.io.IOException;
 
20
import java.io.Serializable;
 
21
import java.util.NoSuchElementException;
 
22
import java.util.Set;
 
23
 
 
24
import com.gs.collections.api.Lazy<name>Iterable;
 
25
import com.gs.collections.api.LazyIterable;
 
26
import com.gs.collections.api.RichIterable;
 
27
import com.gs.collections.api.<name>Iterable;
 
28
import com.gs.collections.api.bag.primitive.Mutable<name>Bag;
 
29
import com.gs.collections.api.block.function.primitive.<name>ToObjectFunction;
 
30
import com.gs.collections.api.block.function.primitive.Object<name>ToObjectFunction;
 
31
import com.gs.collections.api.block.predicate.primitive.Object<name>Predicate;
 
32
import com.gs.collections.api.block.predicate.primitive.<name>Predicate;
 
33
import com.gs.collections.api.block.procedure.Procedure;
 
34
import com.gs.collections.api.block.procedure.primitive.Object<name>Procedure;
 
35
import com.gs.collections.api.block.procedure.primitive.<name>Procedure;
 
36
import com.gs.collections.api.collection.ImmutableCollection;
 
37
import com.gs.collections.api.collection.primitive.Immutable<name>Collection;
 
38
import com.gs.collections.api.collection.primitive.Mutable<name>Collection;
 
39
import com.gs.collections.api.iterator.<name>Iterator;
 
40
import com.gs.collections.api.list.primitive.Mutable<name>List;
 
41
import com.gs.collections.api.map.primitive.ImmutableObject<name>Map;
 
42
import com.gs.collections.api.map.primitive.Object<name>Map;
 
43
import com.gs.collections.api.set.primitive.Mutable<name>Set;
 
44
import com.gs.collections.api.tuple.primitive.Object<name>Pair;
 
45
import com.gs.collections.impl.bag.mutable.primitive.<name>HashBag;
 
46
import com.gs.collections.impl.collection.mutable.primitive.Unmodifiable<name>Collection;
 
47
import com.gs.collections.impl.factory.Lists;
 
48
import com.gs.collections.impl.factory.Sets;
 
49
import com.gs.collections.impl.factory.primitive.<name>Lists;
 
50
import com.gs.collections.impl.lazy.primitive.Lazy<name>IterableAdapter;
 
51
import com.gs.collections.impl.list.mutable.primitive.<name>ArrayList;
 
52
import com.gs.collections.impl.set.mutable.primitive.<name>HashSet;
 
53
import com.gs.collections.impl.utility.LazyIterate;
 
54
 
 
55
/**
 
56
 * ImmutableObject<name>EmptyMap is an optimization for {@link ImmutableObject<name>Map} of size 0.
 
57
 * This file was automatically generated from template file immutableObjectPrimitiveEmptyMap.stg.
 
58
 *
 
59
 * @since 4.0.
 
60
 */
 
61
final class ImmutableObject<name>EmptyMap\<K> implements ImmutableObject<name>Map\<K>, Serializable
 
62
{
 
63
    private static final long serialVersionUID = 1L;
 
64
    private static final <type> EMPTY_VALUE = <zero.(type)>;
 
65
    static final ImmutableObject<name>Map\<?> INSTANCE = new ImmutableObject<name>EmptyMap\<Object>();
 
66
 
 
67
    private Object readResolve()
 
68
    {
 
69
        return INSTANCE;
 
70
    }
 
71
 
 
72
    public <name>Iterator <type>Iterator()
 
73
    {
 
74
        return new Internal<name>Iterator();
 
75
    }
 
76
 
 
77
    private static class Internal<name>Iterator implements <name>Iterator
 
78
    {
 
79
        public boolean hasNext()
 
80
        {
 
81
            return false;
 
82
        }
 
83
 
 
84
        public <type> next()
 
85
        {
 
86
            throw new NoSuchElementException();
 
87
        }
 
88
    }
 
89
 
 
90
    public void forEach(<name>Procedure procedure)
 
91
    {
 
92
    }
 
93
 
 
94
    public int count(<name>Predicate predicate)
 
95
    {
 
96
        return 0;
 
97
    }
 
98
 
 
99
    public boolean anySatisfy(<name>Predicate predicate)
 
100
    {
 
101
        return false;
 
102
    }
 
103
 
 
104
    public boolean allSatisfy(<name>Predicate predicate)
 
105
    {
 
106
        return true;
 
107
    }
 
108
 
 
109
    public boolean noneSatisfy(<name>Predicate predicate)
 
110
    {
 
111
        return true;
 
112
    }
 
113
 
 
114
    public Immutable<name>Collection select(<name>Predicate predicate)
 
115
    {
 
116
        return <name>Lists.immutable.with();
 
117
    }
 
118
 
 
119
    public Immutable<name>Collection reject(<name>Predicate predicate)
 
120
    {
 
121
        return <name>Lists.immutable.with();
 
122
    }
 
123
 
 
124
    public <type> detectIfNone(<name>Predicate predicate, <type> ifNone)
 
125
    {
 
126
        return ifNone;
 
127
    }
 
128
 
 
129
    public \<V> ImmutableCollection\<V> collect(<name>ToObjectFunction\<? extends V> function)
 
130
    {
 
131
        return Lists.immutable.of();
 
132
    }
 
133
 
 
134
    <(arithmeticMethods.(type))()>
 
135
    public <type>[] toArray()
 
136
    {
 
137
        return new <type>[0];
 
138
    }
 
139
 
 
140
    public boolean contains(<type> value)
 
141
    {
 
142
        return false;
 
143
    }
 
144
 
 
145
    public boolean containsAll(<type>... source)
 
146
    {
 
147
        return source.length == 0;
 
148
    }
 
149
 
 
150
    public boolean containsAll(<name>Iterable source)
 
151
    {
 
152
        return source.isEmpty();
 
153
    }
 
154
 
 
155
    public Mutable<name>List toList()
 
156
    {
 
157
        return new <name>ArrayList();
 
158
    }
 
159
 
 
160
    public Mutable<name>Set toSet()
 
161
    {
 
162
        return new <name>HashSet();
 
163
    }
 
164
 
 
165
    public Mutable<name>Bag toBag()
 
166
    {
 
167
        return new <name>HashBag();
 
168
    }
 
169
 
 
170
    public Lazy<name>Iterable asLazy()
 
171
    {
 
172
        return new Lazy<name>IterableAdapter(this);
 
173
    }
 
174
 
 
175
    public ImmutableObject<name>Map\<K> newWithKeyValue(K key, <type> value)
 
176
    {
 
177
        return new ImmutableObject<name>SingletonMap\<K>(key, value);
 
178
    }
 
179
 
 
180
    public ImmutableObject<name>Map\<K> newWithoutKey(K key)
 
181
    {
 
182
        return this;
 
183
    }
 
184
 
 
185
    public ImmutableObject<name>Map\<K> newWithoutAllKeys(Iterable\<? extends K> keys)
 
186
    {
 
187
        return this;
 
188
    }
 
189
 
 
190
    public <type> get(Object key)
 
191
    {
 
192
        return EMPTY_VALUE;
 
193
    }
 
194
 
 
195
    public <type> getOrThrow(Object key)
 
196
    {
 
197
        throw new IllegalStateException("Key " + key + " not present.");
 
198
    }
 
199
 
 
200
    public <type> getIfAbsent(Object key, <type> ifAbsent)
 
201
    {
 
202
        return ifAbsent;
 
203
    }
 
204
 
 
205
    public boolean containsKey(Object key)
 
206
    {
 
207
        return false;
 
208
    }
 
209
 
 
210
    public boolean containsValue(<type> value)
 
211
    {
 
212
        return false;
 
213
    }
 
214
 
 
215
    public void forEachValue(<name>Procedure procedure)
 
216
    {
 
217
    }
 
218
 
 
219
    public void forEachKey(Procedure\<? super K> procedure)
 
220
    {
 
221
    }
 
222
 
 
223
    public void forEachKeyValue(Object<name>Procedure\<? super K> object<name>Procedure)
 
224
    {
 
225
    }
 
226
 
 
227
    public ImmutableObject<name>Map\<K> select(Object<name>Predicate\<? super K> object<name>Predicate)
 
228
    {
 
229
        return this;
 
230
    }
 
231
 
 
232
    public ImmutableObject<name>Map\<K> reject(Object<name>Predicate\<? super K> object<name>Predicate)
 
233
    {
 
234
        return this;
 
235
    }
 
236
 
 
237
    public ImmutableObject<name>Map\<K> toImmutable()
 
238
    {
 
239
        return this;
 
240
    }
 
241
 
 
242
    public int size()
 
243
    {
 
244
        return 0;
 
245
    }
 
246
 
 
247
    public boolean isEmpty()
 
248
    {
 
249
        return true;
 
250
    }
 
251
 
 
252
    public boolean notEmpty()
 
253
    {
 
254
        return false;
 
255
    }
 
256
 
 
257
    public \<T> T injectInto(T injectedValue, Object<name>ToObjectFunction\<? super T, ? extends T> function)
 
258
    {
 
259
        return injectedValue;
 
260
    }
 
261
 
 
262
    public Set\<K> keySet()
 
263
    {
 
264
        return Sets.immutable.\<K>of().castToSet();
 
265
    }
 
266
 
 
267
    public Mutable<name>Collection values()
 
268
    {
 
269
        return Unmodifiable<name>Collection.of(new <name>ArrayList());
 
270
    }
 
271
 
 
272
    public LazyIterable\<K> keysView()
 
273
    {
 
274
        return LazyIterate.empty();
 
275
    }
 
276
 
 
277
    public RichIterable\<Object<name>Pair\<K>\> keyValuesView()
 
278
    {
 
279
        return LazyIterate.empty();
 
280
    }
 
281
 
 
282
    @Override
 
283
    public boolean equals(Object obj)
 
284
    {
 
285
        if (obj == this)
 
286
        {
 
287
            return true;
 
288
        }
 
289
        if (!(obj instanceof Object<name>Map))
 
290
        {
 
291
            return false;
 
292
        }
 
293
        Object<name>Map\<K> map = (Object<name>Map\<K>) obj;
 
294
        return map.isEmpty();
 
295
    }
 
296
 
 
297
    @Override
 
298
    public int hashCode()
 
299
    {
 
300
        return 0;
 
301
    }
 
302
 
 
303
    @Override
 
304
    public String toString()
 
305
    {
 
306
        return "{}";
 
307
    }
 
308
 
 
309
    public String makeString()
 
310
    {
 
311
        return "";
 
312
    }
 
313
 
 
314
    public String makeString(String separator)
 
315
    {
 
316
        return "";
 
317
    }
 
318
 
 
319
    public String makeString(String start, String separator, String end)
 
320
    {
 
321
        return start + end;
 
322
    }
 
323
 
 
324
    public void appendString(Appendable appendable)
 
325
    {
 
326
    }
 
327
 
 
328
    public void appendString(Appendable appendable, String separator)
 
329
    {
 
330
    }
 
331
 
 
332
    public void appendString(Appendable appendable, String start, String separator, String end)
 
333
    {
 
334
        try
 
335
        {
 
336
            appendable.append(start);
 
337
            appendable.append(end);
 
338
        }
 
339
        catch (IOException e)
 
340
        {
 
341
            throw new RuntimeException(e);
 
342
        }
 
343
    }
 
344
}
 
345
 
 
346
>>
 
347
 
 
348
arithmeticMethods ::= [
 
349
    "byte": "allMethods",
 
350
    "short": "allMethods",
 
351
    "char": "allMethods",
 
352
    "int": "allMethods",
 
353
    "long": "allMethods",
 
354
    "float": "allMethods",
 
355
    "double": "allMethods",
 
356
    "boolean": "noMethods"
 
357
    ]
 
358
 
 
359
allMethods() ::= <<
 
360
public <wideType.(type)> sum()
 
361
{
 
362
    return <wideZero.(type)>;
 
363
}
 
364
 
 
365
public <type> min()
 
366
{
 
367
    throw new NoSuchElementException();
 
368
}
 
369
 
 
370
public <type> max()
 
371
{
 
372
    throw new NoSuchElementException();
 
373
}
 
374
 
 
375
public <type> maxIfEmpty(<type> defaultValue)
 
376
{
 
377
    return defaultValue;
 
378
}
 
379
 
 
380
public <type> minIfEmpty(<type> defaultValue)
 
381
{
 
382
    return defaultValue;
 
383
}
 
384
 
 
385
public double average()
 
386
{
 
387
    throw new ArithmeticException();
 
388
}
 
389
 
 
390
public double median()
 
391
{
 
392
    throw new ArithmeticException();
 
393
}
 
394
 
 
395
public <type>[] toSortedArray()
 
396
{
 
397
    return new <type>[0];
 
398
}
 
399
 
 
400
public Mutable<name>List toSortedList()
 
401
{
 
402
    return new <name>ArrayList();
 
403
}
 
404
 
 
405
>>
 
406
 
 
407
noMethods() ::= ""