/** * converts B into T with Mapper, ignores null-values */ public <T> Flow<T> map(Mapper<? super B, T> mapper) { return then(new FlowMap<B, T>(mapper)); }
public Flow<B> skipUntil(Filter<? super B> skipUntil) { return then(new FlowSkipUntil<B>(skipUntil)); }
public FlowCount<B> count() { return then(new FlowCount<B>()); }
public FlowAllMatch<B> all(Filter<B> filter) { return then(new FlowAllMatch<B>(filter)); }
/** * converts B into T with Mapper, ignores null-values */ public <T> Flow<T> map(Mapper<? super B, T> mapper) { return then(new FlowMap<B, T>(mapper)); }
public Flow<B> skipUntil(Filter<? super B> skipUntil) { return then(new FlowSkipUntil<B>(skipUntil)); }
public FlowFirst<B> first(B def) { return then(new FlowFirst<B>(def)); }
public FlowLast<B> last(B def) { return then(new FlowLast<B>(def)); }
@Override protected void process() { FlowProcessor<T, ?> child = this.child; for (Flow<T> flow : flows) { if (stop) break; flow.then(noopOnEnd).then(child); start(flow); } } };
@Override protected void process() { FlowProcessor<T, ?> child = this.child; for (Flow<T> flow : flows) { if (stop) break; flow.then(noopOnEnd).then(child); start(flow); } } };
@Override public void process(final B b) { mapper.map(b); b.getLast().then(new FlowOnEnd<V>(new FlowProcessor<V, V>() { @Override public void process(V v) { result.put(b.getKey(), v); } })); } }
@Override public void process(final B b) { mapper.map(b); b.getLast().then(new FlowOnEnd<V>(new FlowProcessor<V, V>() { @Override public void process(V v) { result.put(b.getKey(), v); } })); } }
@Test public void test_of_floats() { Assert.assertEquals("1.0,2.0,3.0", Flow.of(new float[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new float[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_doubles() { Assert.assertEquals("1.0,2.0,3.0", Flow.of(new double[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new double[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_bytes() { Assert.assertEquals("1,2,3", Flow.of(new byte[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new byte[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_longs() { Assert.assertEquals("1,2,3", Flow.of(new long[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new long[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_chars() { Assert.assertEquals("a,b,c", Flow.of(new char[]{'a', 'b', 'c'}).join(",").get()); IllegalState flow = Flow.of(new char[]{'a', 'b', 'c'}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_booleans() { Assert.assertEquals("true,false", Flow.of(new boolean[]{true, false}).join(",").get()); IllegalState flow = Flow.of(new boolean[]{true, false}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_ints() { Assert.assertEquals("1,2,3", Flow.of(new int[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new int[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }
@Test public void test_of_shorts() { Assert.assertEquals("1,2,3", Flow.of(new short[]{1, 2, 3}).join(",").get()); IllegalState flow = Flow.of(new short[]{1, 2, 3}).then(new IllegalState()); flow.stop(); flow.execute(); }