@Test public void shouldBeMappableUsingMapperOnSecondPosition() throws Exception { Pair<Integer, String> pair = tuple(5, "Five"); Mapper<String, Integer> mapper = new Mapper<String, Integer>() { @Override public Integer map(String input) { return input.length(); } }; Pair<Integer, Integer> expected = tuple(5, 4); Pair<Integer, Integer> actual = pair.mapSecond(mapper); assertThat(actual, is(expected)); }
@Override public <A> Pair<R, A> mapSecond(UnaryFunction<S, A> function) { return pair(getFirst(), function.call(getSecond())); }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<R, A> mapSecond(UnaryFunction<S, A> function) { return pair(getFirst(), function.call(getSecond())); } }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<R, A> mapSecond(UnaryFunction<S, A> function) { return pair(getFirst(), function.call(getSecond())); } Pair(R first, S second); }
Pair extends Single<R> implements Second<S>,
                   MappableSecond<S, Pair<R, ?>> { @Override public <A> Pair<R, A> mapSecond(UnaryFunction<S, A> function) { return pair(getFirst(), function.call(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<R, A> mapSecond(UnaryFunction<S, A> function) { return pair(getFirst(), function.call(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();  }