-
Notifications
You must be signed in to change notification settings - Fork 587
/
mutablePrimitivePrimitiveMapFactoryImpl.stg
93 lines (75 loc) · 2.73 KB
/
mutablePrimitivePrimitiveMapFactoryImpl.stg
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
import "copyright.stg"
hasTwoPrimitives() ::= "true"
skipBooleanKeys() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/map/mutable/primitive"
fileName(primitive1, primitive2, sameTwoPrimitives) ::= "Mutable<primitive1.name><primitive2.name>MapFactoryImpl"
class(primitive1, primitive2, sameTwoPrimitives) ::= <<
<body(primitive1.type, primitive2.type, primitive1.name, primitive2.name)>
>>
body(type1, type2, name1, name2) ::= <<
<copyright()>
package org.eclipse.collections.impl.map.mutable.primitive;
import org.eclipse.collections.api.block.function.primitive.<name1>Function;
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.block.function.primitive.<name2>Function;<endif>
import org.eclipse.collections.api.factory.map.primitive.Mutable<name1><name2>MapFactory;
import org.eclipse.collections.impl.factory.primitive.<name1><name2>Maps;
import org.eclipse.collections.api.map.primitive.Mutable<name1><name2>Map;
import org.eclipse.collections.api.map.primitive.<name1><name2>Map;
import org.eclipse.collections.impl.utility.Iterate;
/**
* Mutable<name1><name2>MapFactoryImpl is a factory implementation which creates instances of type {@link Mutable<name1><name2>Map}.
* This file was automatically generated from template file mutablePrimitivePrimitiveMapFactoryImpl.stg.
*
* @since 6.0.
*/
public enum Mutable<name1><name2>MapFactoryImpl implements Mutable<name1><name2>MapFactory
{
INSTANCE;
@Override
public Mutable<name1><name2>Map empty()
{
return new <name1><name2>HashMap(0);
}
@Override
public Mutable<name1><name2>Map of()
{
return this.empty();
}
@Override
public Mutable<name1><name2>Map with()
{
return this.empty();
}
@Override
public Mutable<name1><name2>Map ofInitialCapacity(int capacity)
{
return this.withInitialCapacity(capacity);
}
@Override
public Mutable<name1><name2>Map withInitialCapacity(int capacity)
{
return new <name1><name2>HashMap(capacity);
}
@Override
public Mutable<name1><name2>Map ofAll(<name1><name2>Map map)
{
return this.withAll(map);
}
@Override
public Mutable<name1><name2>Map withAll(<name1><name2>Map map)
{
if (map.isEmpty())
{
return this.empty();
}
return new <name1><name2>HashMap(map);
}
@Override
public \<T> Mutable<name1><name2>Map from(Iterable\<T> iterable, <name1>Function\<? super T> keyFunction, <name2>Function\<? super T> valueFunction)
{
Mutable<name1><name2>Map map = <name1><name2>Maps.mutable.empty();
Iterate.forEach(iterable, each -> map.put(keyFunction.<type1>ValueOf(each), valueFunction.<type2>ValueOf(each)));
return map;
}
}
>>