2
import "primitiveEquals.stg"
3
import "primitiveHashCode.stg"
4
import "primitiveLiteral.stg"
6
targetPath() ::= "com/gs/collections/impl/map/immutable/primitive"
8
fileName(primitive) ::= "ImmutableObject<primitive.name>EmptyMap"
10
class(primitive) ::= <<
11
<body(primitive.type, primitive.name)>
14
body(type, name) ::= <<
17
package com.gs.collections.impl.map.immutable.primitive;
19
import java.io.IOException;
20
import java.io.Serializable;
21
import java.util.NoSuchElementException;
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;
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.
61
final class ImmutableObject<name>EmptyMap\<K> implements ImmutableObject<name>Map\<K>, Serializable
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>();
67
private Object readResolve()
72
public <name>Iterator <type>Iterator()
74
return new Internal<name>Iterator();
77
private static class Internal<name>Iterator implements <name>Iterator
79
public boolean hasNext()
86
throw new NoSuchElementException();
90
public void forEach(<name>Procedure procedure)
94
public int count(<name>Predicate predicate)
99
public boolean anySatisfy(<name>Predicate predicate)
104
public boolean allSatisfy(<name>Predicate predicate)
109
public boolean noneSatisfy(<name>Predicate predicate)
114
public Immutable<name>Collection select(<name>Predicate predicate)
116
return <name>Lists.immutable.with();
119
public Immutable<name>Collection reject(<name>Predicate predicate)
121
return <name>Lists.immutable.with();
124
public <type> detectIfNone(<name>Predicate predicate, <type> ifNone)
129
public \<V> ImmutableCollection\<V> collect(<name>ToObjectFunction\<? extends V> function)
131
return Lists.immutable.of();
134
<(arithmeticMethods.(type))()>
135
public <type>[] toArray()
137
return new <type>[0];
140
public boolean contains(<type> value)
145
public boolean containsAll(<type>... source)
147
return source.length == 0;
150
public boolean containsAll(<name>Iterable source)
152
return source.isEmpty();
155
public Mutable<name>List toList()
157
return new <name>ArrayList();
160
public Mutable<name>Set toSet()
162
return new <name>HashSet();
165
public Mutable<name>Bag toBag()
167
return new <name>HashBag();
170
public Lazy<name>Iterable asLazy()
172
return new Lazy<name>IterableAdapter(this);
175
public ImmutableObject<name>Map\<K> newWithKeyValue(K key, <type> value)
177
return new ImmutableObject<name>SingletonMap\<K>(key, value);
180
public ImmutableObject<name>Map\<K> newWithoutKey(K key)
185
public ImmutableObject<name>Map\<K> newWithoutAllKeys(Iterable\<? extends K> keys)
190
public <type> get(Object key)
195
public <type> getOrThrow(Object key)
197
throw new IllegalStateException("Key " + key + " not present.");
200
public <type> getIfAbsent(Object key, <type> ifAbsent)
205
public boolean containsKey(Object key)
210
public boolean containsValue(<type> value)
215
public void forEachValue(<name>Procedure procedure)
219
public void forEachKey(Procedure\<? super K> procedure)
223
public void forEachKeyValue(Object<name>Procedure\<? super K> object<name>Procedure)
227
public ImmutableObject<name>Map\<K> select(Object<name>Predicate\<? super K> object<name>Predicate)
232
public ImmutableObject<name>Map\<K> reject(Object<name>Predicate\<? super K> object<name>Predicate)
237
public ImmutableObject<name>Map\<K> toImmutable()
247
public boolean isEmpty()
252
public boolean notEmpty()
257
public \<T> T injectInto(T injectedValue, Object<name>ToObjectFunction\<? super T, ? extends T> function)
259
return injectedValue;
262
public Set\<K> keySet()
264
return Sets.immutable.\<K>of().castToSet();
267
public Mutable<name>Collection values()
269
return Unmodifiable<name>Collection.of(new <name>ArrayList());
272
public LazyIterable\<K> keysView()
274
return LazyIterate.empty();
277
public RichIterable\<Object<name>Pair\<K>\> keyValuesView()
279
return LazyIterate.empty();
283
public boolean equals(Object obj)
289
if (!(obj instanceof Object<name>Map))
293
Object<name>Map\<K> map = (Object<name>Map\<K>) obj;
294
return map.isEmpty();
298
public int hashCode()
304
public String toString()
309
public String makeString()
314
public String makeString(String separator)
319
public String makeString(String start, String separator, String end)
324
public void appendString(Appendable appendable)
328
public void appendString(Appendable appendable, String separator)
332
public void appendString(Appendable appendable, String start, String separator, String end)
336
appendable.append(start);
337
appendable.append(end);
339
catch (IOException e)
341
throw new RuntimeException(e);
348
arithmeticMethods ::= [
349
"byte": "allMethods",
350
"short": "allMethods",
351
"char": "allMethods",
353
"long": "allMethods",
354
"float": "allMethods",
355
"double": "allMethods",
356
"boolean": "noMethods"
360
public <wideType.(type)> sum()
362
return <wideZero.(type)>;
367
throw new NoSuchElementException();
372
throw new NoSuchElementException();
375
public <type> maxIfEmpty(<type> defaultValue)
380
public <type> minIfEmpty(<type> defaultValue)
385
public double average()
387
throw new ArithmeticException();
390
public double median()
392
throw new ArithmeticException();
395
public <type>[] toSortedArray()
397
return new <type>[0];
400
public Mutable<name>List toSortedList()
402
return new <name>ArrayList();