@Override default Stream<T> update(int index, Function<? super T, ? extends T> updater) { Objects.requireNonNull(updater, "updater is null"); return update(index, updater.apply(get(index))); }
static IntervalFunction of(long intervalMillis, Function<Long, Long> backoffFunction) { checkInterval(intervalMillis); requireNonNull(backoffFunction); return (attempt) -> { checkAttempt(attempt); return Stream.iterate(intervalMillis, backoffFunction).get(attempt - 1); }; }
@Override default Stream<T> update(int index, Function<? super T, ? extends T> updater) { Objects.requireNonNull(updater, "updater is null"); return update(index, updater.apply(get(index))); }
@Test public void testStream() throws Exception { Stream<A> src = Stream.of(new B("a", "b")); String json = MAPPER.writeValueAsString(new StreamPojo().setValue(src)); Assert.assertEquals(json, "{\"value\":[{\"ExtFieldsPojoTest$B\":{\"a\":\"a\",\"b\":\"b\"}}]}"); StreamPojo pojo = MAPPER.readValue(json, StreamPojo.class); Stream<A> restored = pojo.getValue(); Assert.assertTrue(restored.get(0) instanceof B); Assert.assertEquals(restored.get(0).a, "a"); Assert.assertEquals(((B) restored.get(0)).b, "b"); }
@Test public void testStream() throws Exception { Stream<I> src = Stream.of(new A(), new B()); String json = MAPPER.writeValueAsString(new StreamPojo().setValue(src)); Assert.assertEquals(json, "{\"value\":[{\"type\":\"a\"},{\"type\":\"b\"}]}"); StreamPojo pojo = MAPPER.readValue(json, StreamPojo.class); Stream<I> restored = pojo.getValue(); Assert.assertTrue(restored.get(0) instanceof A); Assert.assertTrue(restored.get(1) instanceof B); }