PagedList extends ArrayList<HttpResponse<T>> { public PagedList<T> ifSuccess(Consumer<HttpResponse<T>> consumer) { stream().filter(HttpResponse::isSuccess).forEach(consumer); return this; }  List<T> getBodies(); PagedList<T> ifSuccess(Consumer<HttpResponse<T>> consumer); PagedList<T> ifFailure(Consumer<HttpResponse<T>> consumer);  }
@Test public void canProcessSuccessfullResuls() { PagedList<String> list = new PagedList<>(); list.addAll(asList( mkRequest("foo"), mkRequest(null), mkRequest("baz") )); final List<String> processed = new ArrayList<>(); list.ifSuccess(e -> processed.add(e.getBody())); assertEquals(Arrays.asList("foo","baz"), processed); }