@@ -21,8 +21,7 @@ private Functions() {
21
21
}
22
22
23
23
/**
24
- * Converts a {@link Func0} to a {@link FuncN} to allow heterogeneous handling of functions with different
25
- * arities.
24
+ * Converts a {@link Func0} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
26
25
*
27
26
* @param f
28
27
* the {@code Func0} to convert
@@ -43,8 +42,7 @@ public R call(Object... args) {
43
42
}
44
43
45
44
/**
46
- * Converts a {@link Func1} to a {@link FuncN} to allow heterogeneous handling of functions with different
47
- * arities.
45
+ * Converts a {@link Func1} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
48
46
*
49
47
* @param f
50
48
* the {@code Func1} to convert
@@ -66,8 +64,7 @@ public R call(Object... args) {
66
64
}
67
65
68
66
/**
69
- * Converts a {@link Func2} to a {@link FuncN} to allow heterogeneous handling of functions with different
70
- * arities.
67
+ * Converts a {@link Func2} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
71
68
*
72
69
* @param f
73
70
* the {@code Func2} to convert
@@ -89,8 +86,7 @@ public R call(Object... args) {
89
86
}
90
87
91
88
/**
92
- * Converts a {@link Func3} to a {@link FuncN} to allow heterogeneous handling of functions with different
93
- * arities.
89
+ * Converts a {@link Func3} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
94
90
*
95
91
* @param f
96
92
* the {@code Func3} to convert
@@ -112,8 +108,7 @@ public R call(Object... args) {
112
108
}
113
109
114
110
/**
115
- * Converts a {@link Func4} to a {@link FuncN} to allow heterogeneous handling of functions with different
116
- * arities.
111
+ * Converts a {@link Func4} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
117
112
*
118
113
* @param f
119
114
* the {@code Func4} to convert
@@ -135,8 +130,7 @@ public R call(Object... args) {
135
130
}
136
131
137
132
/**
138
- * Converts a {@link Func5} to a {@link FuncN} to allow heterogeneous handling of functions with different
139
- * arities.
133
+ * Converts a {@link Func5} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
140
134
*
141
135
* @param f
142
136
* the {@code Func5} to convert
@@ -158,8 +152,7 @@ public R call(Object... args) {
158
152
}
159
153
160
154
/**
161
- * Converts a {@link Func6} to a {@link FuncN} to allow heterogeneous handling of functions with different
162
- * arities.
155
+ * Converts a {@link Func6} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
163
156
*
164
157
* @param f
165
158
* the {@code Func6} to convert
@@ -181,8 +174,7 @@ public R call(Object... args) {
181
174
}
182
175
183
176
/**
184
- * Converts a {@link Func7} to a {@link FuncN} to allow heterogeneous handling of functions with different
185
- * arities.
177
+ * Converts a {@link Func7} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
186
178
*
187
179
* @param f
188
180
* the {@code Func7} to convert
@@ -204,8 +196,7 @@ public R call(Object... args) {
204
196
}
205
197
206
198
/**
207
- * Converts a {@link Func8} to a {@link FuncN} to allow heterogeneous handling of functions with different
208
- * arities.
199
+ * Converts a {@link Func8} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
209
200
*
210
201
* @param f
211
202
* the {@code Func8} to convert
@@ -227,8 +218,7 @@ public R call(Object... args) {
227
218
}
228
219
229
220
/**
230
- * Converts a {@link Func9} to a {@link FuncN} to allow heterogeneous handling of functions with different
231
- * arities.
221
+ * Converts a {@link Func9} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
232
222
*
233
223
* @param f
234
224
* the {@code Func9} to convert
@@ -250,8 +240,7 @@ public R call(Object... args) {
250
240
}
251
241
252
242
/**
253
- * Converts an {@link Action0} to a {@link FuncN} to allow heterogeneous handling of functions with
254
- * different arities.
243
+ * Converts an {@link Action0} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
255
244
*
256
245
* @param f
257
246
* the {@code Action0} to convert
@@ -273,8 +262,7 @@ public Void call(Object... args) {
273
262
}
274
263
275
264
/**
276
- * Converts an {@link Action1} to a {@link FuncN} to allow heterogeneous handling of functions with
277
- * different arities.
265
+ * Converts an {@link Action1} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
278
266
*
279
267
* @param f
280
268
* the {@code Action1} to convert
@@ -297,8 +285,7 @@ public Void call(Object... args) {
297
285
}
298
286
299
287
/**
300
- * Converts an {@link Action2} to a {@link FuncN} to allow heterogeneous handling of functions with
301
- * different arities.
288
+ * Converts an {@link Action2} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
302
289
*
303
290
* @param f
304
291
* the {@code Action2} to convert
@@ -321,8 +308,7 @@ public Void call(Object... args) {
321
308
}
322
309
323
310
/**
324
- * Converts an {@link Action3} to a {@link FuncN} to allow heterogeneous handling of functions with
325
- * different arities.
311
+ * Converts an {@link Action3} to a {@link FuncN} to allow heterogeneous handling of functions with different arities.
326
312
*
327
313
* @param f
328
314
* the {@code Action3} to convert
@@ -344,134 +330,4 @@ public Void call(Object... args) {
344
330
};
345
331
}
346
332
347
- /**
348
- * Returns a function that always returns {@code true}.
349
- *
350
- * @return a {@link Func1} that accepts an Object and returns the Boolean {@code true}
351
- */
352
- public static <T > Func1 <? super T , Boolean > alwaysTrue () {
353
- return AlwaysTrue .INSTANCE ;
354
- }
355
-
356
- /**
357
- * Returns a function that always returns {@code false}.
358
- *
359
- * @return a {@link Func1} that accepts an Object and returns the Boolean {@code false}
360
- */
361
- public static <T > Func1 <? super T , Boolean > alwaysFalse () {
362
- return AlwaysFalse .INSTANCE ;
363
- }
364
-
365
- /**
366
- * Returns a function that always returns the Object it is passed.
367
- *
368
- * @return a {@link Func1} that accepts an Object and returns the same Object
369
- */
370
- public static <T > Func1 <T , T > identity () {
371
- return new Func1 <T , T >() {
372
- @ Override
373
- public T call (T o ) {
374
- return o ;
375
- }
376
- };
377
- }
378
-
379
- private enum AlwaysTrue implements Func1 <Object , Boolean > {
380
- INSTANCE ;
381
-
382
- @ Override
383
- public Boolean call (Object o ) {
384
- return true ;
385
- }
386
- }
387
-
388
- private enum AlwaysFalse implements Func1 <Object , Boolean > {
389
- INSTANCE ;
390
-
391
- @ Override
392
- public Boolean call (Object o ) {
393
- return false ;
394
- }
395
- }
396
-
397
- /**
398
- * Returns a function that merely returns {@code null}, without side effects.
399
- *
400
- * @return a function that returns {@code null}
401
- */
402
- @ SuppressWarnings ("unchecked" )
403
- public static <T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , R > NullFunction <T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , R > returnNull () {
404
- return NULL_FUNCTION ;
405
- }
406
-
407
- @ SuppressWarnings ("rawtypes" )
408
- private static final NullFunction NULL_FUNCTION = new NullFunction ();
409
-
410
- private static final class NullFunction <T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , R > implements
411
- Func0 <R >,
412
- Func1 <T0 , R >,
413
- Func2 <T0 , T1 , R >,
414
- Func3 <T0 , T1 , T2 , R >,
415
- Func4 <T0 , T1 , T2 , T3 , R >,
416
- Func5 <T0 , T1 , T2 , T3 , T4 , R >,
417
- Func6 <T0 , T1 , T2 , T3 , T4 , T5 , R >,
418
- Func7 <T0 , T1 , T2 , T3 , T4 , T5 , T6 , R >,
419
- Func8 <T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , R >,
420
- Func9 <T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , R >,
421
- FuncN <R > {
422
- @ Override
423
- public R call () {
424
- return null ;
425
- }
426
-
427
- @ Override
428
- public R call (T0 t1 ) {
429
- return null ;
430
- }
431
-
432
- @ Override
433
- public R call (T0 t1 , T1 t2 ) {
434
- return null ;
435
- }
436
-
437
- @ Override
438
- public R call (T0 t1 , T1 t2 , T2 t3 ) {
439
- return null ;
440
- }
441
-
442
- @ Override
443
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 ) {
444
- return null ;
445
- }
446
-
447
- @ Override
448
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 , T4 t5 ) {
449
- return null ;
450
- }
451
-
452
- @ Override
453
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 , T4 t5 , T5 t6 ) {
454
- return null ;
455
- }
456
-
457
- @ Override
458
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 , T4 t5 , T5 t6 , T6 t7 ) {
459
- return null ;
460
- }
461
-
462
- @ Override
463
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 , T4 t5 , T5 t6 , T6 t7 , T7 t8 ) {
464
- return null ;
465
- }
466
-
467
- @ Override
468
- public R call (T0 t1 , T1 t2 , T2 t3 , T3 t4 , T4 t5 , T5 t6 , T6 t7 , T7 t8 , T8 t9 ) {
469
- return null ;
470
- }
471
-
472
- @ Override
473
- public R call (Object ... args ) {
474
- return null ;
475
- }
476
- }
477
333
}
0 commit comments