Skip to content

Commit

Permalink
[#80] Loosen Tuple.map[N](Function1<T[N], U[N]>) to be
Browse files Browse the repository at this point in the history
map[N](Function1<? super T[N], ? extends U[N])
  • Loading branch information
lukaseder committed Jan 22, 2015
1 parent a063f9f commit 10e1874
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jooq/lambda/tuple/Tuple1.java
Expand Up @@ -112,7 +112,7 @@ public final <R> R map(Function1<T1, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple1<U1> map1(Function1<T1, U1> function) {
public final <U1> Tuple1<U1> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jooq/lambda/tuple/Tuple2.java
Expand Up @@ -159,14 +159,14 @@ public final <R> R map(Function2<T1, T2, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple2<U1, T2> map1(Function1<T1, U1> function) {
public final <U1> Tuple2<U1, T2> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple2<T1, U2> map2(Function1<T2, U2> function) {
public final <U2> Tuple2<T1, U2> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2));
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jooq/lambda/tuple/Tuple3.java
Expand Up @@ -115,21 +115,21 @@ public final <R> R map(Function3<T1, T2, T3, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple3<U1, T2, T3> map1(Function1<T1, U1> function) {
public final <U1> Tuple3<U1, T2, T3> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple3<T1, U2, T3> map2(Function1<T2, U2> function) {
public final <U2> Tuple3<T1, U2, T3> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple3<T1, T2, U3> map3(Function1<T3, U3> function) {
public final <U3> Tuple3<T1, T2, U3> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3));
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jooq/lambda/tuple/Tuple4.java
Expand Up @@ -116,28 +116,28 @@ public final <R> R map(Function4<T1, T2, T3, T4, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple4<U1, T2, T3, T4> map1(Function1<T1, U1> function) {
public final <U1> Tuple4<U1, T2, T3, T4> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple4<T1, U2, T3, T4> map2(Function1<T2, U2> function) {
public final <U2> Tuple4<T1, U2, T3, T4> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple4<T1, T2, U3, T4> map3(Function1<T3, U3> function) {
public final <U3> Tuple4<T1, T2, U3, T4> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4);
}

/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U4> Tuple4<T1, T2, T3, U4> map4(Function1<T4, U4> function) {
public final <U4> Tuple4<T1, T2, T3, U4> map4(Function1<? super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4));
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jooq/lambda/tuple/Tuple5.java
Expand Up @@ -117,35 +117,35 @@ public final <R> R map(Function5<T1, T2, T3, T4, T5, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple5<U1, T2, T3, T4, T5> map1(Function1<T1, U1> function) {
public final <U1> Tuple5<U1, T2, T3, T4, T5> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4, v5);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple5<T1, U2, T3, T4, T5> map2(Function1<T2, U2> function) {
public final <U2> Tuple5<T1, U2, T3, T4, T5> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4, v5);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple5<T1, T2, U3, T4, T5> map3(Function1<T3, U3> function) {
public final <U3> Tuple5<T1, T2, U3, T4, T5> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4, v5);
}

/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U4> Tuple5<T1, T2, T3, U4, T5> map4(Function1<T4, U4> function) {
public final <U4> Tuple5<T1, T2, T3, U4, T5> map4(Function1<? super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4), v5);
}

/**
* Apply attribute 5 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U5> Tuple5<T1, T2, T3, T4, U5> map5(Function1<T5, U5> function) {
public final <U5> Tuple5<T1, T2, T3, T4, U5> map5(Function1<? super T5, ? extends U5> function) {
return Tuple.tuple(v1, v2, v3, v4, function.apply(v5));
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/jooq/lambda/tuple/Tuple6.java
Expand Up @@ -118,42 +118,42 @@ public final <R> R map(Function6<T1, T2, T3, T4, T5, T6, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple6<U1, T2, T3, T4, T5, T6> map1(Function1<T1, U1> function) {
public final <U1> Tuple6<U1, T2, T3, T4, T5, T6> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4, v5, v6);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple6<T1, U2, T3, T4, T5, T6> map2(Function1<T2, U2> function) {
public final <U2> Tuple6<T1, U2, T3, T4, T5, T6> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4, v5, v6);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple6<T1, T2, U3, T4, T5, T6> map3(Function1<T3, U3> function) {
public final <U3> Tuple6<T1, T2, U3, T4, T5, T6> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4, v5, v6);
}

/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U4> Tuple6<T1, T2, T3, U4, T5, T6> map4(Function1<T4, U4> function) {
public final <U4> Tuple6<T1, T2, T3, U4, T5, T6> map4(Function1<? super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4), v5, v6);
}

/**
* Apply attribute 5 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U5> Tuple6<T1, T2, T3, T4, U5, T6> map5(Function1<T5, U5> function) {
public final <U5> Tuple6<T1, T2, T3, T4, U5, T6> map5(Function1<? super T5, ? extends U5> function) {
return Tuple.tuple(v1, v2, v3, v4, function.apply(v5), v6);
}

/**
* Apply attribute 6 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U6> Tuple6<T1, T2, T3, T4, T5, U6> map6(Function1<T6, U6> function) {
public final <U6> Tuple6<T1, T2, T3, T4, T5, U6> map6(Function1<? super T6, ? extends U6> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, function.apply(v6));
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/jooq/lambda/tuple/Tuple7.java
Expand Up @@ -119,49 +119,49 @@ public final <R> R map(Function7<T1, T2, T3, T4, T5, T6, T7, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple7<U1, T2, T3, T4, T5, T6, T7> map1(Function1<T1, U1> function) {
public final <U1> Tuple7<U1, T2, T3, T4, T5, T6, T7> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4, v5, v6, v7);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple7<T1, U2, T3, T4, T5, T6, T7> map2(Function1<T2, U2> function) {
public final <U2> Tuple7<T1, U2, T3, T4, T5, T6, T7> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4, v5, v6, v7);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple7<T1, T2, U3, T4, T5, T6, T7> map3(Function1<T3, U3> function) {
public final <U3> Tuple7<T1, T2, U3, T4, T5, T6, T7> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4, v5, v6, v7);
}

/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U4> Tuple7<T1, T2, T3, U4, T5, T6, T7> map4(Function1<T4, U4> function) {
public final <U4> Tuple7<T1, T2, T3, U4, T5, T6, T7> map4(Function1<? super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4), v5, v6, v7);
}

/**
* Apply attribute 5 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U5> Tuple7<T1, T2, T3, T4, U5, T6, T7> map5(Function1<T5, U5> function) {
public final <U5> Tuple7<T1, T2, T3, T4, U5, T6, T7> map5(Function1<? super T5, ? extends U5> function) {
return Tuple.tuple(v1, v2, v3, v4, function.apply(v5), v6, v7);
}

/**
* Apply attribute 6 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U6> Tuple7<T1, T2, T3, T4, T5, U6, T7> map6(Function1<T6, U6> function) {
public final <U6> Tuple7<T1, T2, T3, T4, T5, U6, T7> map6(Function1<? super T6, ? extends U6> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, function.apply(v6), v7);
}

/**
* Apply attribute 7 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U7> Tuple7<T1, T2, T3, T4, T5, T6, U7> map7(Function1<T7, U7> function) {
public final <U7> Tuple7<T1, T2, T3, T4, T5, T6, U7> map7(Function1<? super T7, ? extends U7> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, v6, function.apply(v7));
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/jooq/lambda/tuple/Tuple8.java
Expand Up @@ -113,56 +113,56 @@ public final <R> R map(Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> function) {
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U1> Tuple8<U1, T2, T3, T4, T5, T6, T7, T8> map1(Function1<T1, U1> function) {
public final <U1> Tuple8<U1, T2, T3, T4, T5, T6, T7, T8> map1(Function1<? super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4, v5, v6, v7, v8);
}

/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U2> Tuple8<T1, U2, T3, T4, T5, T6, T7, T8> map2(Function1<T2, U2> function) {
public final <U2> Tuple8<T1, U2, T3, T4, T5, T6, T7, T8> map2(Function1<? super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4, v5, v6, v7, v8);
}

/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U3> Tuple8<T1, T2, U3, T4, T5, T6, T7, T8> map3(Function1<T3, U3> function) {
public final <U3> Tuple8<T1, T2, U3, T4, T5, T6, T7, T8> map3(Function1<? super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4, v5, v6, v7, v8);
}

/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U4> Tuple8<T1, T2, T3, U4, T5, T6, T7, T8> map4(Function1<T4, U4> function) {
public final <U4> Tuple8<T1, T2, T3, U4, T5, T6, T7, T8> map4(Function1<? super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4), v5, v6, v7, v8);
}

/**
* Apply attribute 5 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U5> Tuple8<T1, T2, T3, T4, U5, T6, T7, T8> map5(Function1<T5, U5> function) {
public final <U5> Tuple8<T1, T2, T3, T4, U5, T6, T7, T8> map5(Function1<? super T5, ? extends U5> function) {
return Tuple.tuple(v1, v2, v3, v4, function.apply(v5), v6, v7, v8);
}

/**
* Apply attribute 6 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U6> Tuple8<T1, T2, T3, T4, T5, U6, T7, T8> map6(Function1<T6, U6> function) {
public final <U6> Tuple8<T1, T2, T3, T4, T5, U6, T7, T8> map6(Function1<? super T6, ? extends U6> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, function.apply(v6), v7, v8);
}

/**
* Apply attribute 7 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U7> Tuple8<T1, T2, T3, T4, T5, T6, U7, T8> map7(Function1<T7, U7> function) {
public final <U7> Tuple8<T1, T2, T3, T4, T5, T6, U7, T8> map7(Function1<? super T7, ? extends U7> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, v6, function.apply(v7), v8);
}

/**
* Apply attribute 8 as argument to a function and return a new tuple with the substituted argument.
*/
public final <U8> Tuple8<T1, T2, T3, T4, T5, T6, T7, U8> map8(Function1<T8, U8> function) {
public final <U8> Tuple8<T1, T2, T3, T4, T5, T6, T7, U8> map8(Function1<? super T8, ? extends U8> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, v6, v7, function.apply(v8));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jooq/lambda/SeqTest.java
Expand Up @@ -433,7 +433,7 @@ public void testGroupBy() {

Map<Integer, Tuple2<Long, String>> map4 =
Seq.of(tuple(1, 1), tuple(1, 2), tuple(1, 3), tuple(2, 4), tuple(2, 5))
.groupBy(t -> t.v1, collectors(counting(), mapping(t -> "" + t.v2, joining(", "))));
.groupBy(t -> t.v1, collectors(counting(), mapping(t -> t.map2(Object::toString).v2, joining(", "))));
assertEquals(3L, (long) map4.get(1).v1);
assertEquals(2L, (long) map4.get(2).v1);
assertEquals("1, 2, 3", map4.get(1).v2);
Expand Down

0 comments on commit 10e1874

Please sign in to comment.