functionalj.stream.StreamableWithGet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalj-core Show documentation
Show all versions of functionalj-core Show documentation
The module for FunctionalJ Core.
package functionalj.stream;
import java.util.concurrent.atomic.AtomicLong;
import functionalj.tuple.Tuple;
import functionalj.tuple.Tuple2;
import functionalj.tuple.Tuple3;
import functionalj.tuple.Tuple4;
import functionalj.tuple.Tuple5;
import functionalj.tuple.Tuple6;
import lombok.val;
public interface StreamableWithGet {
public StreamPlus stream();
public IteratorPlus iterator();
//-- 1 --
@SuppressWarnings("unchecked")
public default T get(StreamElementProcessor processor) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor.processElement(index, each);
}
val count = counter.get();
return processor.processComplete(count);
}
public default T get(StreamProcessor processor) {
val stream = this.stream();
val target = processor.process(stream);
return target;
}
//-- 2 --
@SuppressWarnings("unchecked")
public default Tuple2 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2) {
val counter = new AtomicLong(0);
for (val each : ((Iterable< DATA>)this)) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
return Tuple.of(value1, value2);
}
@SuppressWarnings("unchecked")
public default Tuple2 get(
StreamElementProcessor processor1,
StreamProcessor processor2) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
return Tuple.of(value1, value2);
}
@SuppressWarnings("unchecked")
public default Tuple2 get(
StreamProcessor processor1,
StreamElementProcessor processor2) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
return Tuple.of(value1, value2);
}
public default Tuple2 get(
StreamProcessor processor1,
StreamProcessor processor2) {
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
return Tuple.of(value1, value2);
}
//-- 3 --
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
return Tuple.of(value1, value2, value3);
}
@SuppressWarnings("unchecked")
public default Tuple3 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
return Tuple.of(value1, value2, value3);
}
public default Tuple3 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3) {
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
return Tuple.of(value1, value2, value3);
}
//-- 4 --
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor3.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor4.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor3.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
@SuppressWarnings("unchecked")
public default Tuple4 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamProcessor processor4) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
public default Tuple4 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamProcessor processor4) {
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.process(stream());
return Tuple.of(value1, value2, value3, value4);
}
//-- 5 --
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor3.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamElementProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor3.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.processComplete(count);
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamElementProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor2.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamProcessor processor1,
StreamElementProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor2.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.processComplete(count);
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamElementProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor1.processElement(index, each);
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.processComplete(count);
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamProcessor processor1,
StreamProcessor processor2,
StreamProcessor processor3,
StreamElementProcessor processor4,
StreamElementProcessor processor5) {
val counter = new AtomicLong(0);
for (val each : (Iterable)this) {
val index = counter.getAndIncrement();
processor4.processElement(index, each);
processor5.processElement(index, each);
}
val count = counter.get();
val value1 = processor1.process(stream());
val value2 = processor2.process(stream());
val value3 = processor3.process(stream());
val value4 = processor4.processComplete(count);
val value5 = processor5.processComplete(count);
return Tuple.of(value1, value2, value3, value4, value5);
}
@SuppressWarnings("unchecked")
public default Tuple5 get(
StreamElementProcessor processor1,
StreamElementProcessor