@Test public void testMapItem1() { Tuple2<String, Integer> pair = Tuple2.of("Hello", 42); Tuple2<String, Integer> newPair = pair.mapItem1(String::toUpperCase); assertThat(newPair).containsExactly("HELLO", 42); newPair = pair.mapItem1(s -> null); assertThat(newPair).containsExactly(null, 42); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> pair.mapItem1(s -> { throw new IllegalArgumentException("boom"); })).withMessage("boom"); }
public <T> Tuple2<T, R> mapItem1(Function<L, T> mapper) { return Tuple2.of(mapper.apply(item1), item2); }
Tuple2 implements Tuple { public <T> Tuple2<T, R> mapItem1(Function<L, T> mapper) { return Tuple2.of(mapper.apply(item1), item2); } }
Tuple2 implements Tuple { public <T> Tuple2<T, R> mapItem1(Function<L, T> mapper) { return Tuple2.of(mapper.apply(item1), item2); } protected  Tuple2(L left, R right); }
Tuple2 implements Tuple { public <T> Tuple2<T, R> mapItem1(Function<L, T> mapper) { return Tuple2.of(mapper.apply(item1), item2); } protected  Tuple2(L left, R right); static Tuple2<L, R> of(L l, R r); L getItem1(); R getItem2(); Tuple2<T, R> mapItem1(Function<L, T> mapper); Tuple2<L, T> mapItem2(Function<R, T> mapper); @Override Object nth(int index); @Override List<Object> asList(); @Override boolean equals(Object o); @Override int hashCode(); int size(); @Override String toString(); }
Tuple2 implements Tuple { public <T> Tuple2<T, R> mapItem1(Function<L, T> mapper) { return Tuple2.of(mapper.apply(item1), item2); } protected  Tuple2(L left, R right); static Tuple2<L, R> of(L l, R r); L getItem1(); R getItem2(); Tuple2<T, R> mapItem1(Function<L, T> mapper); Tuple2<L, T> mapItem2(Function<R, T> mapper); @Override Object nth(int index); @Override List<Object> asList(); @Override boolean equals(Object o); @Override int hashCode(); int size(); @Override String toString();  }