-
Notifications
You must be signed in to change notification settings - Fork 590
/
synchronizedPrimitiveBag.stg
251 lines (217 loc) · 6.49 KB
/
synchronizedPrimitiveBag.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
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
249
250
import "copyright.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
targetPath() ::= "org/eclipse/collections/impl/bag/mutable/primitive"
fileName(primitive) ::= "Synchronized<primitive.name>Bag"
class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>
body(type, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.bag.mutable.primitive;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.Lazy<name>Iterable;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.primitive.Immutable<name>Bag;
import org.eclipse.collections.api.bag.primitive.Mutable<name>Bag;
import org.eclipse.collections.api.block.function.primitive.<name>ToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.IntPredicate;
import org.eclipse.collections.api.block.predicate.primitive.<name>Predicate;
import org.eclipse.collections.api.block.procedure.primitive.<name>IntProcedure;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.tuple.primitive.<name>IntPair;
import org.eclipse.collections.impl.collection.mutable.primitive.AbstractSynchronized<name>Collection;
import org.eclipse.collections.impl.factory.primitive.<name>Bags;
import org.eclipse.collections.impl.lazy.primitive.Lazy<name>IterableAdapter;
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
/**
* A synchronized view of a {@link Mutable<name>Bag}. It is imperative that the user manually synchronize on the collection when iterating over it using the
* {@link <name>Iterator}, as per {@link Collections#synchronizedCollection(Collection)}.
* \<p>
* This file was automatically generated from template file synchronizedPrimitiveBag.stg.
*
* @see Mutable<name>Bag#asSynchronized()
* @see MutableBag#asSynchronized()
* @since 3.1.
*/
@ThreadSafe
public final class Synchronized<name>Bag
extends AbstractSynchronized<name>Collection
implements Mutable<name>Bag
{
private static final long serialVersionUID = 1L;
Synchronized<name>Bag(Mutable<name>Bag bag)
{
super(bag);
}
Synchronized<name>Bag(Mutable<name>Bag bag, Object newLock)
{
super(bag, newLock);
}
@GuardedBy("getLock()")
private Mutable<name>Bag getMutable<name>Bag()
{
return (Mutable<name>Bag) this.get<name>Collection();
}
@Override
public Synchronized<name>Bag with(<type> element)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().add(element);
}
return this;
}
@Override
public Synchronized<name>Bag without(<type> element)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().remove(element);
}
return this;
}
@Override
public Synchronized<name>Bag withAll(<name>Iterable elements)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().addAll(elements.toArray());
}
return this;
}
@Override
public Synchronized<name>Bag withoutAll(<name>Iterable elements)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().removeAll(elements);
}
return this;
}
public void addOccurrences(<type> item, int occurrences)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().addOccurrences(item, occurrences);
}
}
public boolean removeOccurrences(<type> item, int occurrences)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().removeOccurrences(item, occurrences);
}
}
public int sizeDistinct()
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().sizeDistinct();
}
}
public int occurrencesOf(<type> item)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().occurrencesOf(item);
}
}
public void forEachWithOccurrences(<name>IntProcedure procedure)
{
synchronized (this.getLock())
{
this.getMutable<name>Bag().forEachWithOccurrences(procedure);
}
}
@Override
public Mutable<name>Bag select(<name>Predicate predicate)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().select(predicate);
}
}
public Mutable<name>Bag selectByOccurrences(IntPredicate predicate)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().selectByOccurrences(predicate);
}
}
public MutableList\<<name>IntPair> topOccurrences(int count)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().topOccurrences(count);
}
}
public MutableList\<<name>IntPair> bottomOccurrences(int count)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().bottomOccurrences(count);
}
}
@Override
public Mutable<name>Bag reject(<name>Predicate predicate)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().reject(predicate);
}
}
@Override
public \<V> MutableBag\<V> collect(<name>ToObjectFunction\<? extends V> function)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().collect(function);
}
}
@Override
public boolean equals(Object otherBag)
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().equals(otherBag);
}
}
@Override
public int hashCode()
{
synchronized (this.getLock())
{
return this.getMutable<name>Bag().hashCode();
}
}
@Override
public Lazy<name>Iterable asLazy()
{
synchronized (this.getLock())
{
return new Lazy<name>IterableAdapter(this);
}
}
@Override
public Mutable<name>Bag asUnmodifiable()
{
return new Unmodifiable<name>Bag(this);
}
@Override
public Mutable<name>Bag asSynchronized()
{
return this;
}
@Override
public Immutable<name>Bag toImmutable()
{
return <name>Bags.immutable.withAll(this);
}
}
>>