@@ -21,8 +21,7 @@ private Functions() {
2121 }
2222
2323 /**
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.
2625 *
2726 * @param f
2827 * the {@code Func0} to convert
@@ -43,8 +42,7 @@ public R call(Object... args) {
4342 }
4443
4544 /**
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.
4846 *
4947 * @param f
5048 * the {@code Func1} to convert
@@ -66,8 +64,7 @@ public R call(Object... args) {
6664 }
6765
6866 /**
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.
7168 *
7269 * @param f
7370 * the {@code Func2} to convert
@@ -89,8 +86,7 @@ public R call(Object... args) {
8986 }
9087
9188 /**
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.
9490 *
9591 * @param f
9692 * the {@code Func3} to convert
@@ -112,8 +108,7 @@ public R call(Object... args) {
112108 }
113109
114110 /**
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.
117112 *
118113 * @param f
119114 * the {@code Func4} to convert
@@ -135,8 +130,7 @@ public R call(Object... args) {
135130 }
136131
137132 /**
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.
140134 *
141135 * @param f
142136 * the {@code Func5} to convert
@@ -158,8 +152,7 @@ public R call(Object... args) {
158152 }
159153
160154 /**
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.
163156 *
164157 * @param f
165158 * the {@code Func6} to convert
@@ -181,8 +174,7 @@ public R call(Object... args) {
181174 }
182175
183176 /**
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.
186178 *
187179 * @param f
188180 * the {@code Func7} to convert
@@ -204,8 +196,7 @@ public R call(Object... args) {
204196 }
205197
206198 /**
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.
209200 *
210201 * @param f
211202 * the {@code Func8} to convert
@@ -227,8 +218,7 @@ public R call(Object... args) {
227218 }
228219
229220 /**
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.
232222 *
233223 * @param f
234224 * the {@code Func9} to convert
@@ -250,8 +240,7 @@ public R call(Object... args) {
250240 }
251241
252242 /**
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.
255244 *
256245 * @param f
257246 * the {@code Action0} to convert
@@ -273,8 +262,7 @@ public Void call(Object... args) {
273262 }
274263
275264 /**
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.
278266 *
279267 * @param f
280268 * the {@code Action1} to convert
@@ -297,8 +285,7 @@ public Void call(Object... args) {
297285 }
298286
299287 /**
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.
302289 *
303290 * @param f
304291 * the {@code Action2} to convert
@@ -321,8 +308,7 @@ public Void call(Object... args) {
321308 }
322309
323310 /**
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.
326312 *
327313 * @param f
328314 * the {@code Action3} to convert
@@ -344,134 +330,4 @@ public Void call(Object... args) {
344330 };
345331 }
346332
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- }
477333}
0 commit comments