@Test public void shouldBeMappableUsingUnaryFunctionOnFirstPosition() throws Exception { Pair<Integer, String> pair = tuple(5, "Five"); UnaryFunction<Integer, String> function = new UnaryFunction<Integer, String>() { @Override public String call(Integer input) { return String.valueOf(input); } }; Pair<String, String> expected = tuple("5", "Five"); Pair<String, String> actual = pair.mapFirst(function); assertThat(actual, is(expected)); }
@Override public <A> Pair<A, S> mapFirst(UnaryFunction<R, A> function) { return pair(function.call(getFirst()), getSecond()); }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<A, S> mapFirst(UnaryFunction<R, A> function) { return pair(function.call(getFirst()), getSecond()); } }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<A, S> mapFirst(UnaryFunction<R, A> function) { return pair(function.call(getFirst()), getSecond()); } Pair(R first, S second); }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<A, S> mapFirst(UnaryFunction<R, A> function) { return pair(function.call(getFirst()), getSecond()); } Pair(R first, S second); static Pair<R, S> pair(R first, S second); @Override S getSecond(); @Override Pair<A, S> mapFirst(UnaryFunction<R, A> function); @Override Pair<R, A> mapSecond(UnaryFunction<S, A> function); @Override Iterable<Object> getValues(); }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<A, S> mapFirst(UnaryFunction<R, A> function) { return pair(function.call(getFirst()), getSecond()); } Pair(R first, S second); static Pair<R, S> pair(R first, S second); @Override S getSecond(); @Override Pair<A, S> mapFirst(UnaryFunction<R, A> function); @Override Pair<R, A> mapSecond(UnaryFunction<S, A> function); @Override Iterable<Object> getValues();  }