Skip to content

Commit 34a5aa6

Browse files
authored
Better parameter naming for CheckedFunction* (#3019)
1 parent 699d664 commit 34a5aa6

19 files changed

+577
-596
lines changed

vavr/generator/Generator.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,6 @@ def generateMainClasses(): Unit = {
15861586
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
15871587
* if the function is defined for the given arguments, and {@code None} otherwise.
15881588
*/
1589-
@SuppressWarnings("RedundantTypeArguments")
15901589
static $fullGenerics ${im.getType(s"io.vavr.Function$i")}$genericsOptionReturnType lift($fullGenericsType partialFunction) {
15911590
${
15921591
val func = "partialFunction"
@@ -1893,7 +1892,7 @@ def generateMainClasses(): Unit = {
18931892
""")}
18941893

18951894
${(1 to i).gen(j => {
1896-
val fName = s"before$j"
1895+
val fName = s"before"
18971896
val fGeneric = "S"
18981897
val applicationArgs = (1 to i).gen(k => if (k == j) s"$fGeneric ${fGeneric.toLowerCase}" else s"T$k t$k")(", ")
18991898
val generics = (1 to i).gen(k => if (k == j) "S" else s"T$k")(", ")

vavr/src-gen/main/java/io/vavr/CheckedFunction0.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ static <R> CheckedFunction0<R> of(CheckedFunction0<R> methodReference) {
104104
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
105105
* if the function is defined for the given arguments, and {@code None} otherwise.
106106
*/
107-
@SuppressWarnings("RedundantTypeArguments")
108107
static <R> Function0<Option<R>> lift(CheckedFunction0<? extends R> partialFunction) {
109108
return () -> Try.<R>of(partialFunction::apply).toOption();
110109
}

vavr/src-gen/main/java/io/vavr/CheckedFunction1.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ static <T1, R> CheckedFunction1<T1, R> of(CheckedFunction1<T1, R> methodReferenc
109109
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
110110
* if the function is defined for the given arguments, and {@code None} otherwise.
111111
*/
112-
@SuppressWarnings("RedundantTypeArguments")
113112
static <T1, R> Function1<T1, Option<R>> lift(CheckedFunction1<? super T1, ? extends R> partialFunction) {
114113
return t1 -> Try.<R>of(() -> partialFunction.apply(t1)).toOption();
115114
}
@@ -300,17 +299,17 @@ default <V> CheckedFunction1<V, R> compose(CheckedFunction1<? super V, ? extends
300299
}
301300

302301
/**
303-
* Returns a composed function that first applies the {@linkplain Function} {@code before1} to the
302+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
304303
* 1st argument and then applies this CheckedFunction1 to the result.
305304
*
306-
* @param <S> argument type of before1
307-
* @param before1 the function applied before this
308-
* @return a function composed of before1 and this
309-
* @throws NullPointerException if before1 is null
305+
* @param <S> argument type of before
306+
* @param before the function applied before this
307+
* @return a function composed of before and this
308+
* @throws NullPointerException if before is null
310309
*/
311-
default <S> CheckedFunction1<S, R> compose1(Function1<? super S, ? extends T1> before1) {
312-
Objects.requireNonNull(before1, "before1 is null");
313-
return (S s) -> apply(before1.apply(s));
310+
default <S> CheckedFunction1<S, R> compose1(Function1<? super S, ? extends T1> before) {
311+
Objects.requireNonNull(before, "before is null");
312+
return (S s) -> apply(before.apply(s));
314313
}
315314
}
316315

vavr/src-gen/main/java/io/vavr/CheckedFunction2.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ static <T1, T2, R> CheckedFunction2<T1, T2, R> of(CheckedFunction2<T1, T2, R> me
114114
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
115115
* if the function is defined for the given arguments, and {@code None} otherwise.
116116
*/
117-
@SuppressWarnings("RedundantTypeArguments")
118117
static <T1, T2, R> Function2<T1, T2, Option<R>> lift(CheckedFunction2<? super T1, ? super T2, ? extends R> partialFunction) {
119118
return (t1, t2) -> Try.<R>of(() -> partialFunction.apply(t1, t2)).toOption();
120119
}
@@ -295,31 +294,31 @@ default <V> CheckedFunction2<T1, T2, V> andThen(CheckedFunction1<? super R, ? ex
295294
}
296295

297296
/**
298-
* Returns a composed function that first applies the {@linkplain Function} {@code before1} to the
297+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
299298
* 1st argument and then applies this CheckedFunction2 to the result and the other argument.
300299
*
301-
* @param <S> argument type of before1
302-
* @param before1 the function applied before this
303-
* @return a function composed of before1 and this
304-
* @throws NullPointerException if before1 is null
300+
* @param <S> argument type of before
301+
* @param before the function applied before this
302+
* @return a function composed of before and this
303+
* @throws NullPointerException if before is null
305304
*/
306-
default <S> CheckedFunction2<S, T2, R> compose1(Function1<? super S, ? extends T1> before1) {
307-
Objects.requireNonNull(before1, "before1 is null");
308-
return (S s, T2 t2) -> apply(before1.apply(s), t2);
305+
default <S> CheckedFunction2<S, T2, R> compose1(Function1<? super S, ? extends T1> before) {
306+
Objects.requireNonNull(before, "before is null");
307+
return (S s, T2 t2) -> apply(before.apply(s), t2);
309308
}
310309

311310
/**
312-
* Returns a composed function that first applies the {@linkplain Function} {@code before2} to the
311+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
313312
* 2nd argument and then applies this CheckedFunction2 to the result and the other argument.
314313
*
315-
* @param <S> argument type of before2
316-
* @param before2 the function applied before this
317-
* @return a function composed of before2 and this
318-
* @throws NullPointerException if before2 is null
314+
* @param <S> argument type of before
315+
* @param before the function applied before this
316+
* @return a function composed of before and this
317+
* @throws NullPointerException if before is null
319318
*/
320-
default <S> CheckedFunction2<T1, S, R> compose2(Function1<? super S, ? extends T2> before2) {
321-
Objects.requireNonNull(before2, "before2 is null");
322-
return (T1 t1, S s) -> apply(t1, before2.apply(s));
319+
default <S> CheckedFunction2<T1, S, R> compose2(Function1<? super S, ? extends T2> before) {
320+
Objects.requireNonNull(before, "before is null");
321+
return (T1 t1, S s) -> apply(t1, before.apply(s));
323322
}
324323
}
325324

vavr/src-gen/main/java/io/vavr/CheckedFunction3.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ static <T1, T2, T3, R> CheckedFunction3<T1, T2, T3, R> of(CheckedFunction3<T1, T
117117
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
118118
* if the function is defined for the given arguments, and {@code None} otherwise.
119119
*/
120-
@SuppressWarnings("RedundantTypeArguments")
121120
static <T1, T2, T3, R> Function3<T1, T2, T3, Option<R>> lift(CheckedFunction3<? super T1, ? super T2, ? super T3, ? extends R> partialFunction) {
122121
return (t1, t2, t3) -> Try.<R>of(() -> partialFunction.apply(t1, t2, t3)).toOption();
123122
}
@@ -312,45 +311,45 @@ default <V> CheckedFunction3<T1, T2, T3, V> andThen(CheckedFunction1<? super R,
312311
}
313312

314313
/**
315-
* Returns a composed function that first applies the {@linkplain Function} {@code before1} to the
314+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
316315
* 1st argument and then applies this CheckedFunction3 to the result and the other arguments.
317316
*
318-
* @param <S> argument type of before1
319-
* @param before1 the function applied before this
320-
* @return a function composed of before1 and this
321-
* @throws NullPointerException if before1 is null
317+
* @param <S> argument type of before
318+
* @param before the function applied before this
319+
* @return a function composed of before and this
320+
* @throws NullPointerException if before is null
322321
*/
323-
default <S> CheckedFunction3<S, T2, T3, R> compose1(Function1<? super S, ? extends T1> before1) {
324-
Objects.requireNonNull(before1, "before1 is null");
325-
return (S s, T2 t2, T3 t3) -> apply(before1.apply(s), t2, t3);
322+
default <S> CheckedFunction3<S, T2, T3, R> compose1(Function1<? super S, ? extends T1> before) {
323+
Objects.requireNonNull(before, "before is null");
324+
return (S s, T2 t2, T3 t3) -> apply(before.apply(s), t2, t3);
326325
}
327326

328327
/**
329-
* Returns a composed function that first applies the {@linkplain Function} {@code before2} to the
328+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
330329
* 2nd argument and then applies this CheckedFunction3 to the result and the other arguments.
331330
*
332-
* @param <S> argument type of before2
333-
* @param before2 the function applied before this
334-
* @return a function composed of before2 and this
335-
* @throws NullPointerException if before2 is null
331+
* @param <S> argument type of before
332+
* @param before the function applied before this
333+
* @return a function composed of before and this
334+
* @throws NullPointerException if before is null
336335
*/
337-
default <S> CheckedFunction3<T1, S, T3, R> compose2(Function1<? super S, ? extends T2> before2) {
338-
Objects.requireNonNull(before2, "before2 is null");
339-
return (T1 t1, S s, T3 t3) -> apply(t1, before2.apply(s), t3);
336+
default <S> CheckedFunction3<T1, S, T3, R> compose2(Function1<? super S, ? extends T2> before) {
337+
Objects.requireNonNull(before, "before is null");
338+
return (T1 t1, S s, T3 t3) -> apply(t1, before.apply(s), t3);
340339
}
341340

342341
/**
343-
* Returns a composed function that first applies the {@linkplain Function} {@code before3} to the
342+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
344343
* 3rd argument and then applies this CheckedFunction3 to the result and the other arguments.
345344
*
346-
* @param <S> argument type of before3
347-
* @param before3 the function applied before this
348-
* @return a function composed of before3 and this
349-
* @throws NullPointerException if before3 is null
345+
* @param <S> argument type of before
346+
* @param before the function applied before this
347+
* @return a function composed of before and this
348+
* @throws NullPointerException if before is null
350349
*/
351-
default <S> CheckedFunction3<T1, T2, S, R> compose3(Function1<? super S, ? extends T3> before3) {
352-
Objects.requireNonNull(before3, "before3 is null");
353-
return (T1 t1, T2 t2, S s) -> apply(t1, t2, before3.apply(s));
350+
default <S> CheckedFunction3<T1, T2, S, R> compose3(Function1<? super S, ? extends T3> before) {
351+
Objects.requireNonNull(before, "before is null");
352+
return (T1 t1, T2 t2, S s) -> apply(t1, t2, before.apply(s));
354353
}
355354
}
356355

vavr/src-gen/main/java/io/vavr/CheckedFunction4.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ static <T1, T2, T3, T4, R> CheckedFunction4<T1, T2, T3, T4, R> of(CheckedFunctio
121121
* @return a function that applies arguments to the given {@code partialFunction} and returns {@code Some(result)}
122122
* if the function is defined for the given arguments, and {@code None} otherwise.
123123
*/
124-
@SuppressWarnings("RedundantTypeArguments")
125124
static <T1, T2, T3, T4, R> Function4<T1, T2, T3, T4, Option<R>> lift(CheckedFunction4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> partialFunction) {
126125
return (t1, t2, t3, t4) -> Try.<R>of(() -> partialFunction.apply(t1, t2, t3, t4)).toOption();
127126
}
@@ -331,59 +330,59 @@ default <V> CheckedFunction4<T1, T2, T3, T4, V> andThen(CheckedFunction1<? super
331330
}
332331

333332
/**
334-
* Returns a composed function that first applies the {@linkplain Function} {@code before1} to the
333+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
335334
* 1st argument and then applies this CheckedFunction4 to the result and the other arguments.
336335
*
337-
* @param <S> argument type of before1
338-
* @param before1 the function applied before this
339-
* @return a function composed of before1 and this
340-
* @throws NullPointerException if before1 is null
336+
* @param <S> argument type of before
337+
* @param before the function applied before this
338+
* @return a function composed of before and this
339+
* @throws NullPointerException if before is null
341340
*/
342-
default <S> CheckedFunction4<S, T2, T3, T4, R> compose1(Function1<? super S, ? extends T1> before1) {
343-
Objects.requireNonNull(before1, "before1 is null");
344-
return (S s, T2 t2, T3 t3, T4 t4) -> apply(before1.apply(s), t2, t3, t4);
341+
default <S> CheckedFunction4<S, T2, T3, T4, R> compose1(Function1<? super S, ? extends T1> before) {
342+
Objects.requireNonNull(before, "before is null");
343+
return (S s, T2 t2, T3 t3, T4 t4) -> apply(before.apply(s), t2, t3, t4);
345344
}
346345

347346
/**
348-
* Returns a composed function that first applies the {@linkplain Function} {@code before2} to the
347+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
349348
* 2nd argument and then applies this CheckedFunction4 to the result and the other arguments.
350349
*
351-
* @param <S> argument type of before2
352-
* @param before2 the function applied before this
353-
* @return a function composed of before2 and this
354-
* @throws NullPointerException if before2 is null
350+
* @param <S> argument type of before
351+
* @param before the function applied before this
352+
* @return a function composed of before and this
353+
* @throws NullPointerException if before is null
355354
*/
356-
default <S> CheckedFunction4<T1, S, T3, T4, R> compose2(Function1<? super S, ? extends T2> before2) {
357-
Objects.requireNonNull(before2, "before2 is null");
358-
return (T1 t1, S s, T3 t3, T4 t4) -> apply(t1, before2.apply(s), t3, t4);
355+
default <S> CheckedFunction4<T1, S, T3, T4, R> compose2(Function1<? super S, ? extends T2> before) {
356+
Objects.requireNonNull(before, "before is null");
357+
return (T1 t1, S s, T3 t3, T4 t4) -> apply(t1, before.apply(s), t3, t4);
359358
}
360359

361360
/**
362-
* Returns a composed function that first applies the {@linkplain Function} {@code before3} to the
361+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
363362
* 3rd argument and then applies this CheckedFunction4 to the result and the other arguments.
364363
*
365-
* @param <S> argument type of before3
366-
* @param before3 the function applied before this
367-
* @return a function composed of before3 and this
368-
* @throws NullPointerException if before3 is null
364+
* @param <S> argument type of before
365+
* @param before the function applied before this
366+
* @return a function composed of before and this
367+
* @throws NullPointerException if before is null
369368
*/
370-
default <S> CheckedFunction4<T1, T2, S, T4, R> compose3(Function1<? super S, ? extends T3> before3) {
371-
Objects.requireNonNull(before3, "before3 is null");
372-
return (T1 t1, T2 t2, S s, T4 t4) -> apply(t1, t2, before3.apply(s), t4);
369+
default <S> CheckedFunction4<T1, T2, S, T4, R> compose3(Function1<? super S, ? extends T3> before) {
370+
Objects.requireNonNull(before, "before is null");
371+
return (T1 t1, T2 t2, S s, T4 t4) -> apply(t1, t2, before.apply(s), t4);
373372
}
374373

375374
/**
376-
* Returns a composed function that first applies the {@linkplain Function} {@code before4} to the
375+
* Returns a composed function that first applies the {@linkplain Function} {@code before} to the
377376
* 4th argument and then applies this CheckedFunction4 to the result and the other arguments.
378377
*
379-
* @param <S> argument type of before4
380-
* @param before4 the function applied before this
381-
* @return a function composed of before4 and this
382-
* @throws NullPointerException if before4 is null
378+
* @param <S> argument type of before
379+
* @param before the function applied before this
380+
* @return a function composed of before and this
381+
* @throws NullPointerException if before is null
383382
*/
384-
default <S> CheckedFunction4<T1, T2, T3, S, R> compose4(Function1<? super S, ? extends T4> before4) {
385-
Objects.requireNonNull(before4, "before4 is null");
386-
return (T1 t1, T2 t2, T3 t3, S s) -> apply(t1, t2, t3, before4.apply(s));
383+
default <S> CheckedFunction4<T1, T2, T3, S, R> compose4(Function1<? super S, ? extends T4> before) {
384+
Objects.requireNonNull(before, "before is null");
385+
return (T1 t1, T2 t2, T3 t3, S s) -> apply(t1, t2, t3, before.apply(s));
387386
}
388387
}
389388

0 commit comments

Comments
 (0)