@@ -73,135 +73,50 @@ public void next() {
73
73
@ Test
74
74
public void mapFilterCount () {
75
75
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
76
- final long count = cursor .map (new Function <VPackSlice , Long >() {
77
- @ Override
78
- public Long apply (final VPackSlice t ) {
79
- return t .getAsLong ();
80
- }
81
- }).filter (new Predicate <Long >() {
82
- @ Override
83
- public boolean test (final Long t ) {
84
- return t < 50 ;
85
- }
86
- }).count ();
76
+ final long count = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).count ();
87
77
assertThat (count , is (50L ));
88
78
}
89
79
90
80
@ Test
91
81
public void mapMapFilterCount () {
92
82
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
93
- final long count = cursor .map (new Function <VPackSlice , Long >() {
94
- @ Override
95
- public Long apply (final VPackSlice t ) {
96
- return t .getAsLong ();
97
- }
98
- }).map (new Function <Long , Long >() {
99
- @ Override
100
- public Long apply (final Long t ) {
101
- return t * 10 ;
102
- }
103
- }).filter (new Predicate <Long >() {
104
- @ Override
105
- public boolean test (final Long t ) {
106
- return t < 500 ;
107
- }
108
- }).count ();
83
+ final long count = cursor .map (VPackSlice ::getAsLong ).map (t -> t * 10 ).filter (t -> t < 500 ).count ();
109
84
assertThat (count , is (50L ));
110
85
}
111
86
112
87
@ Test
113
88
public void mapMapFilterFilterCount () {
114
89
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
115
- final long count = cursor .map (new Function <VPackSlice , Long >() {
116
- @ Override
117
- public Long apply (final VPackSlice t ) {
118
- return t .getAsLong ();
119
- }
120
- }).map (new Function <Long , Long >() {
121
- @ Override
122
- public Long apply (final Long t ) {
123
- return t * 10 ;
124
- }
125
- }).filter (new Predicate <Long >() {
126
- @ Override
127
- public boolean test (final Long t ) {
128
- return t < 500 ;
129
- }
130
- }).filter (new Predicate <Long >() {
131
- @ Override
132
- public boolean test (final Long t ) {
133
- return t < 250 ;
134
- }
135
- }).count ();
90
+ final long count = cursor .map (VPackSlice ::getAsLong ).map (t -> t * 10 ).filter (t -> t < 500 ).filter (t -> t < 250 ).count ();
136
91
assertThat (count , is (25L ));
137
92
}
138
93
139
94
@ Test
140
95
public void mapFilterNext () {
141
96
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
142
- final long count = cursor .map (new Function <VPackSlice , Long >() {
143
- @ Override
144
- public Long apply (final VPackSlice t ) {
145
- return t .getAsLong ();
146
- }
147
- }).filter (new Predicate <Long >() {
148
- @ Override
149
- public boolean test (final Long t ) {
150
- return t < 50 ;
151
- }
152
- }).iterator ().next ();
97
+ final long count = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).iterator ().next ();
153
98
assertThat (count , is (0L ));
154
99
}
155
100
156
101
@ Test
157
102
public void mapFilterFirst () {
158
103
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
159
- final long count = cursor .map (new Function <VPackSlice , Long >() {
160
- @ Override
161
- public Long apply (final VPackSlice t ) {
162
- return t .getAsLong ();
163
- }
164
- }).filter (new Predicate <Long >() {
165
- @ Override
166
- public boolean test (final Long t ) {
167
- return t < 50 ;
168
- }
169
- }).first ();
104
+ final long count = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).first ();
170
105
assertThat (count , is (0L ));
171
106
}
172
107
173
108
@ Test
174
109
public void mapFilterCollectIntoList () {
175
110
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
176
- final List <Long > target = cursor .map (new Function <VPackSlice , Long >() {
177
- @ Override
178
- public Long apply (final VPackSlice t ) {
179
- return t .getAsLong ();
180
- }
181
- }).filter (new Predicate <Long >() {
182
- @ Override
183
- public boolean test (final Long t ) {
184
- return t < 50 ;
185
- }
186
- }).collectInto (new ArrayList <Long >());
111
+ final List <Long > target = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).collectInto (new ArrayList <>());
187
112
assertThat (target , is (not (nullValue ())));
188
113
assertThat (target .size (), is (50 ));
189
114
}
190
115
191
116
@ Test
192
117
public void mapFilterCollectIntoSet () {
193
118
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
194
- final Set <Long > target = cursor .map (new Function <VPackSlice , Long >() {
195
- @ Override
196
- public Long apply (final VPackSlice t ) {
197
- return t .getAsLong ();
198
- }
199
- }).filter (new Predicate <Long >() {
200
- @ Override
201
- public boolean test (final Long t ) {
202
- return t < 50 ;
203
- }
204
- }).collectInto (new HashSet <Long >());
119
+ final Set <Long > target = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).collectInto (new HashSet <>());
205
120
assertThat (target , is (not (nullValue ())));
206
121
assertThat (target .size (), is (50 ));
207
122
}
@@ -210,203 +125,83 @@ public boolean test(final Long t) {
210
125
public void foreach () {
211
126
final AtomicLong i = new AtomicLong (0L );
212
127
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
213
- cursor .foreach (new Consumer <VPackSlice >() {
214
- @ Override
215
- public void accept (final VPackSlice t ) {
216
- assertThat (t .getAsLong (), is (i .getAndIncrement ()));
217
- }
218
- });
128
+ cursor .foreach (t -> assertThat (t .getAsLong (), is (i .getAndIncrement ())));
219
129
}
220
130
221
131
@ Test
222
132
public void mapForeach () {
223
133
final AtomicLong i = new AtomicLong (0L );
224
134
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
225
- cursor .map (new Function <VPackSlice , Long >() {
226
- @ Override
227
- public Long apply (final VPackSlice t ) {
228
- return t .getAsLong ();
229
- }
230
- }).foreach (new Consumer <Long >() {
231
- @ Override
232
- public void accept (final Long t ) {
233
- assertThat (t , is (i .getAndIncrement ()));
234
- }
235
- });
135
+ cursor .map (VPackSlice ::getAsLong ).foreach (t -> assertThat (t , is (i .getAndIncrement ())));
236
136
}
237
137
238
138
@ Test
239
139
public void mapFilterForeach () {
240
140
final AtomicLong i = new AtomicLong (0L );
241
141
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
242
- cursor .map (new Function <VPackSlice , Long >() {
243
- @ Override
244
- public Long apply (final VPackSlice t ) {
245
- return t .getAsLong ();
246
- }
247
- }).filter (new Predicate <Long >() {
248
- @ Override
249
- public boolean test (final Long t ) {
250
- return t < 50 ;
251
- }
252
- }).foreach (new Consumer <Long >() {
253
- @ Override
254
- public void accept (final Long t ) {
255
- assertThat (t , is (i .getAndIncrement ()));
256
- }
257
- });
142
+ cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).foreach (t -> assertThat (t , is (i .getAndIncrement ())));
258
143
}
259
144
260
145
@ Test
261
146
public void anyMatch () {
262
147
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
263
- final boolean match = cursor .anyMatch (new Predicate <VPackSlice >() {
264
- @ Override
265
- public boolean test (final VPackSlice t ) {
266
- return t .getAsLong () == 50L ;
267
- }
268
- });
148
+ final boolean match = cursor .anyMatch (t -> t .getAsLong () == 50L );
269
149
assertThat (match , is (true ));
270
150
}
271
151
272
152
@ Test
273
153
public void mapAnyMatch () {
274
154
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
275
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
276
- @ Override
277
- public Long apply (final VPackSlice t ) {
278
- return t .getAsLong ();
279
- }
280
- }).anyMatch (new Predicate <Long >() {
281
- @ Override
282
- public boolean test (final Long t ) {
283
- return t == 50L ;
284
- }
285
- });
155
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).anyMatch (t -> t == 50L );
286
156
assertThat (match , is (true ));
287
157
}
288
158
289
159
@ Test
290
160
public void mapFilterAnyMatch () {
291
161
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
292
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
293
- @ Override
294
- public Long apply (final VPackSlice t ) {
295
- return t .getAsLong ();
296
- }
297
- }).filter (new Predicate <Long >() {
298
- @ Override
299
- public boolean test (final Long t ) {
300
- return t < 50 ;
301
- }
302
- }).anyMatch (new Predicate <Long >() {
303
- @ Override
304
- public boolean test (final Long t ) {
305
- return t == 25L ;
306
- }
307
- });
162
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).anyMatch (t -> t == 25L );
308
163
assertThat (match , is (true ));
309
164
}
310
165
311
166
@ Test
312
167
public void noneMatch () {
313
168
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
314
- final boolean match = cursor .noneMatch (new Predicate <VPackSlice >() {
315
- @ Override
316
- public boolean test (final VPackSlice t ) {
317
- return t .getAsLong () == 100L ;
318
- }
319
- });
169
+ final boolean match = cursor .noneMatch (t -> t .getAsLong () == 100L );
320
170
assertThat (match , is (true ));
321
171
}
322
172
323
173
@ Test
324
174
public void mapNoneMatch () {
325
175
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
326
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
327
- @ Override
328
- public Long apply (final VPackSlice t ) {
329
- return t .getAsLong ();
330
- }
331
- }).noneMatch (new Predicate <Long >() {
332
- @ Override
333
- public boolean test (final Long t ) {
334
- return t == 100L ;
335
- }
336
- });
176
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).noneMatch (t -> t == 100L );
337
177
assertThat (match , is (true ));
338
178
}
339
179
340
180
@ Test
341
181
public void mapFilterNoneMatch () {
342
182
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
343
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
344
- @ Override
345
- public Long apply (final VPackSlice t ) {
346
- return t .getAsLong ();
347
- }
348
- }).filter (new Predicate <Long >() {
349
- @ Override
350
- public boolean test (final Long t ) {
351
- return t < 50 ;
352
- }
353
- }).noneMatch (new Predicate <Long >() {
354
- @ Override
355
- public boolean test (final Long t ) {
356
- return t == 50L ;
357
- }
358
- });
183
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).noneMatch (t -> t == 50L );
359
184
assertThat (match , is (true ));
360
185
}
361
186
362
187
@ Test
363
188
public void allMatch () {
364
189
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
365
- final boolean match = cursor .allMatch (new Predicate <VPackSlice >() {
366
- @ Override
367
- public boolean test (final VPackSlice t ) {
368
- return t .getAsLong () < 100L ;
369
- }
370
- });
190
+ final boolean match = cursor .allMatch (t -> t .getAsLong () < 100L );
371
191
assertThat (match , is (true ));
372
192
}
373
193
374
194
@ Test
375
195
public void mapAllMatch () {
376
196
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
377
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
378
- @ Override
379
- public Long apply (final VPackSlice t ) {
380
- return t .getAsLong ();
381
- }
382
- }).allMatch (new Predicate <Long >() {
383
- @ Override
384
- public boolean test (final Long t ) {
385
- return t < 100 ;
386
- }
387
- });
197
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).allMatch (t -> t < 100 );
388
198
assertThat (match , is (true ));
389
199
}
390
200
391
201
@ Test
392
202
public void mapFilterAllMatch () {
393
203
final ArangoCursor <VPackSlice > cursor = db .query ("FOR i IN 0..99 RETURN i" , VPackSlice .class );
394
- final boolean match = cursor .map (new Function <VPackSlice , Long >() {
395
- @ Override
396
- public Long apply (final VPackSlice t ) {
397
- return t .getAsLong ();
398
- }
399
- }).filter (new Predicate <Long >() {
400
- @ Override
401
- public boolean test (final Long t ) {
402
- return t < 50 ;
403
- }
404
- }).allMatch (new Predicate <Long >() {
405
- @ Override
406
- public boolean test (final Long t ) {
407
- return t < 50 ;
408
- }
409
- });
204
+ final boolean match = cursor .map (VPackSlice ::getAsLong ).filter (t -> t < 50 ).allMatch (t -> t < 50 );
410
205
assertThat (match , is (true ));
411
206
}
412
207
}
0 commit comments