-
Notifications
You must be signed in to change notification settings - Fork 587
/
immutablePrimitiveBagFactoryImpl.stg
171 lines (145 loc) · 3.75 KB
/
immutablePrimitiveBagFactoryImpl.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
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
import "copyrightAndOthers.stg"
targetPath() ::= "org/eclipse/collections/impl/bag/immutable/primitive"
fileName(primitive) ::= "Immutable<primitive.name>BagFactoryImpl"
class(primitive) ::= <<
<body(primitive.type, primitive.name, primitive.wrapperName)>
>>
body(type, name, wrapperName) ::= <<
<copyrightAndOthers()>
package org.eclipse.collections.impl.bag.immutable.primitive;
import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.bag.primitive.Immutable<name>Bag;
import org.eclipse.collections.api.factory.bag.primitive.Immutable<name>BagFactory;
import org.eclipse.collections.impl.factory.primitive.<name>Bags;
<(wideStreamImport.(type))>
/**
* Immutable<name>BagFactoryImpl is a factory implementation which creates instances of type {@link Immutable<name>Bag}.
* This file was automatically generated from template file immutablePrimitiveBagFactoryImpl.stg.
*
* @since 4.0.
*/
public class Immutable<name>BagFactoryImpl implements Immutable<name>BagFactory
{
public static final Immutable<name>BagFactory INSTANCE = new Immutable<name>BagFactoryImpl();
@Override
public Immutable<name>Bag empty()
{
return Immutable<name>EmptyBag.INSTANCE;
}
@Override
public Immutable<name>Bag of()
{
return this.empty();
}
@Override
public Immutable<name>Bag with()
{
return this.empty();
}
@Override
public Immutable<name>Bag of(<type> one)
{
return this.with(one);
}
@Override
public Immutable<name>Bag with(<type> one)
{
return new Immutable<name>SingletonBag(one);
}
@Override
public Immutable<name>Bag of(<type>... items)
{
return this.with(items);
}
@Override
public Immutable<name>Bag with(<type>... items)
{
if (items == null || items.length == 0)
{
return this.with();
}
if (items.length == 1)
{
return this.with(items[0]);
}
return Immutable<name>HashBag.newBagWith(items);
}
@Override
public Immutable<name>Bag ofAll(<name>Iterable items)
{
return this.withAll(items);
}
@Override
public Immutable<name>Bag withAll(<name>Iterable items)
{
if (items instanceof Immutable<name>Bag)
{
return (Immutable<name>Bag) items;
}
return this.with(items.toArray());
}
/**
* @since 10.0
*/
@Override
public Immutable<name>Bag ofAll(Iterable\<<wrapperName>\> iterable)
{
return this.withAll(iterable);
}
/**
* @since 10.0
*/
@Override
public Immutable<name>Bag withAll(Iterable\<<wrapperName>\> iterable)
{
return <name>Bags.mutable.withAll(iterable).toImmutable();
}
<(streamMethods.(type))()>
}
>>
streamMethods ::= [
"byte": "noMethods",
"short": "noMethods",
"char": "noMethods",
"int": "allMethods",
"long": "allMethods",
"float": "noMethods",
"double": "allMethods",
"boolean": "noMethods"
]
allMethods() ::= <<
/**
* @since 9.0
*/
@Override
public Immutable<name>Bag ofAll(<(wideStream.(type))> items)
{
return this.withAll(items);
}
/**
* @since 9.0
*/
@Override
public Immutable<name>Bag withAll(<(wideStream.(type))> items)
{
return this.with(items.toArray());
}
>>
noMethods() ::= ""
wideStream ::= [
"int": "IntStream",
"long": "LongStream",
"double": "DoubleStream",
default: "no matching wide type"
]
wideStreamImport ::= [
"boolean": "",
"byte": "",
"short": "",
"char": "",
"int": "import java.util.stream.IntStream;",
"long": "import java.util.stream.LongStream;",
"float": "",
"double": "import java.util.stream.DoubleStream;",
default: "no matching wide type"
]