From 471786d9193e2091cd5d60a652a2c7a3fc60d410 Mon Sep 17 00:00:00 2001 From: John McClean Date: Thu, 11 Jun 2015 11:01:11 +0100 Subject: [PATCH] v0.95 release --- build.gradle | 2 +- .../simple/react/stream/BaseSimpleReact.java | 4 +- .../simple/react/stream/eager/EagerReact.java | 1 - .../simple/react/stream/lazy/LazyReact.java | 1 - .../stream/traits/EagerFutureStream.java | 92 ++++++++++++------- 5 files changed, 63 insertions(+), 37 deletions(-) diff --git a/build.gradle b/build.gradle index 8e72f3e5f0..03a5f0ec53 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'jacoco' apply from: custom('jacoco-version') sourceCompatibility = 1.8 -version = '1.0.0' +version = '0.95' jar { manifest { attributes 'Implementation-Title': 'Simple React', 'Implementation-Version': version diff --git a/src/main/java/com/aol/simple/react/stream/BaseSimpleReact.java b/src/main/java/com/aol/simple/react/stream/BaseSimpleReact.java index 8ea520f9ff..808a6c9d0a 100644 --- a/src/main/java/com/aol/simple/react/stream/BaseSimpleReact.java +++ b/src/main/java/com/aol/simple/react/stream/BaseSimpleReact.java @@ -43,7 +43,6 @@ public SimpleReactStream range(int startInclusive, int endExclusive){ * Start a reactive flow from a JDK Iterator * * @param iterator SimpleReact will iterate over this iterator concurrently to start the reactive dataflow - * @param maxTimes Maximum number of iterations * @return Next stage in the reactive flow */ @SuppressWarnings("unchecked") @@ -68,8 +67,7 @@ public SimpleReactStream of(final Collection collection){ /** * Start a reactive flow from a JDK Iterator * - * @param iterator SimpleReact will iterate over this iterator concurrently to start the reactive dataflow - * @param maxTimes Maximum number of iterations + * @param iter SimpleReact will iterate over this iterator concurrently to start the reactive dataflow * @return Next stage in the reactive flow */ @SuppressWarnings("unchecked") diff --git a/src/main/java/com/aol/simple/react/stream/eager/EagerReact.java b/src/main/java/com/aol/simple/react/stream/eager/EagerReact.java index 7ba8a83f97..2f152a0a35 100644 --- a/src/main/java/com/aol/simple/react/stream/eager/EagerReact.java +++ b/src/main/java/com/aol/simple/react/stream/eager/EagerReact.java @@ -191,7 +191,6 @@ public EagerFutureStream react(Collection> actions) { * Start a LazyFutureStream from a JDK Iterator * * @param iterator SimpleReact will iterate over this iterator concurrently to start the reactive dataflow - * @param maxTimes Maximum number of iterations * @return Next stage in the reactive flow */ @Override diff --git a/src/main/java/com/aol/simple/react/stream/lazy/LazyReact.java b/src/main/java/com/aol/simple/react/stream/lazy/LazyReact.java index 2b7c375caf..0d35110f06 100644 --- a/src/main/java/com/aol/simple/react/stream/lazy/LazyReact.java +++ b/src/main/java/com/aol/simple/react/stream/lazy/LazyReact.java @@ -227,7 +227,6 @@ public LazyFutureStream react(Collection> actions) { * Start a LazyFutureStream from a JDK Iterator * * @param iterator SimpleReact will iterate over this iterator concurrently to start the reactive dataflow - * @param maxTimes Maximum number of iterations * @return Next stage in the reactive flow */ @Override diff --git a/src/main/java/com/aol/simple/react/stream/traits/EagerFutureStream.java b/src/main/java/com/aol/simple/react/stream/traits/EagerFutureStream.java index 23c6844072..8338f5503e 100644 --- a/src/main/java/com/aol/simple/react/stream/traits/EagerFutureStream.java +++ b/src/main/java/com/aol/simple/react/stream/traits/EagerFutureStream.java @@ -2,22 +2,15 @@ import static java.util.Spliterator.ORDERED; import static java.util.Spliterators.spliteratorUnknownSize; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import java.io.IOException; -import java.io.Serializable; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Random; -import java.util.TreeSet; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.concurrent.Executors; @@ -30,24 +23,19 @@ import java.util.function.Supplier; import java.util.stream.Collector; import java.util.stream.Collectors; -import java.util.stream.IntStream; import java.util.stream.Stream; import java.util.stream.StreamSupport; import org.jooq.lambda.Seq; import org.jooq.lambda.tuple.Tuple; import org.jooq.lambda.tuple.Tuple2; -import org.pcollections.HashTreePMap; import com.aol.simple.react.RetryBuilder; import com.aol.simple.react.async.Continueable; import com.aol.simple.react.async.Queue; -import com.aol.simple.react.async.QueueFactories; import com.aol.simple.react.async.QueueFactory; -import com.aol.simple.react.async.Queue.ClosedQueueException; import com.aol.simple.react.collectors.lazy.LazyResultConsumer; import com.aol.simple.react.exceptions.SimpleReactFailedStageException; -import com.aol.simple.react.predicates.Predicates; import com.aol.simple.react.stream.StreamWrapper; import com.aol.simple.react.stream.ThreadPools; import com.aol.simple.react.stream.eager.EagerFutureStreamImpl; @@ -239,7 +227,7 @@ default EagerFutureStream> chunkSinceLastRead() { * * Stream evenStream = evenQueue.stream(); * } - * + * * * * results in 2 Streams "even": 10,20,30 "odd" : 25,41,43 @@ -933,6 +921,19 @@ default EagerFutureStream retry(Function fn) { } /* + *
+	 * {@code 
+	 * Set result = new EagerReact()
+								. react(() -> 1, () -> 2, () -> 3, () -> 5)
+								.then( it -> it*100)
+								.allOf(Collectors.toSet(), it -> it.size())
+								.first();
+			
+	 * 
+	 * }
+	 * 
+	 * 
+ * * (non-Javadoc) * * @see @@ -946,6 +947,21 @@ default EagerFutureStream allOf(Collector collector, return (EagerFutureStream) FutureStream.super.allOf(collector, fn); } + /* + *
+	 * {@code 
+	 * 				new EagerReact().react(() -> 1)
+	 * 								.then(this::load)
+									.anyOf(this::process)
+									.first();
+	 * 
+	 * }
+	 * 
+	 * 
+ * + * + * @see com.aol.simple.react.stream.traits.FutureStream#anyOf(java.util.function.Function) + */ default EagerFutureStream anyOf(Function fn) { return (EagerFutureStream) FutureStream.super.anyOf(fn); @@ -1081,10 +1097,14 @@ default EagerFutureStream skip(long n) { /** * Concatenate two streams. * + *
+	 * {@code 
+	 * // (1, 2, 3, 4, 5, 6) 
+	 *  EagerFutureStream.of(1, 2,3).concat(Stream.of(4, 5, 6))
 	 * 
-	 * // (1, 2, 3, 4, 5, 6) EagerFutureStream.of(1, 2,
-	 * 3).concat(EagerFutureStream.of(4, 5, 6))
 	 * 
+	 * }
+	 * 
* * @see #concat(Stream[]) */ @@ -1095,7 +1115,19 @@ default EagerFutureStream concat(Stream other) { return (EagerFutureStream) merge((SimpleReactStream) other); return fromStream(FutureStream.super.concat(other)); } - + /** + * Concatenate two streams. + * + *
+	 * {@code 
+	 * // (1, 2, 3, 4, 5, 6) 
+	 *  EagerFutureStream.of(1, 2,3).concat(EagerFutureStream.of(4, 5, 6))
+	 * 
+	 * 
+	 * }
+	 * 
+ * @see #concat(Stream[]) + */ default FutureStream concat(SimpleReactStream other) { return (EagerFutureStream) merge((SimpleReactStream) other); @@ -1130,28 +1162,16 @@ default EagerFutureStream concat(U... other) { .of(other)); } - /** - * Repeat a stream infinitely. - * - * - * // (1, 2, 3, 1, 2, 3, ...) EagerFutureStream.of(1, 2, 3).cycle(); - * - * - * @see #cycle(Stream) - * **/ - @Override - default EagerFutureStream cycle() { return - fromStream(FutureStream.super.cycle()); - } + /** * Returns a limited interval from a given Stream. * * - * // (4, 5) EagerFutureStream.of(1, 2, 3, 4, 5, 6).slice(3, 5) + * // (4, 5) EagerFutureStream.of(1, 2, 3, 4, 5, 6).sliceFutures(3, 5) * * - * @see #slice(Stream, long, long) + * @see #slice(long, long) */ default EagerFutureStream sliceFutures(long from, long to) { @@ -1160,6 +1180,16 @@ default EagerFutureStream sliceFutures(long from, long to) { return fromListCompletableFuture(noType); } + /** + * Returns a limited interval from a given Stream. + * + * + * // (4, 5) EagerFutureStream.of(1, 2, 3, 4, 5, 6).slice(3, 5) + * + * + * @see #slice(Stream, long, long) + */ + @Override default EagerFutureStream slice(long from, long to) {