diff --git a/bingo/bingo-elastic/java/src/main/java/com/epam/indigo/elastic/ElasticStream.java b/bingo/bingo-elastic/java/src/main/java/com/epam/indigo/elastic/ElasticStream.java index 74e6c92b23..be791de769 100644 --- a/bingo/bingo-elastic/java/src/main/java/com/epam/indigo/elastic/ElasticStream.java +++ b/bingo/bingo-elastic/java/src/main/java/com/epam/indigo/elastic/ElasticStream.java @@ -34,6 +34,7 @@ import java.util.Spliterator; import java.util.function.*; import java.util.stream.Collector; +import java.util.stream.Collectors; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; @@ -262,12 +263,12 @@ public boolean noneMatch(Predicate predicate) { @Override public Optional findFirst() { - throw new BingoElasticException("findFirst() operation on this stream isn't implemented"); + return this.limit(1).collect(Collectors.toList()).stream().findFirst(); } @Override public Optional findAny() { - throw new BingoElasticException("findAny() operation on this stream isn't implemented"); + return findFirst(); } @Override @@ -342,22 +343,22 @@ public Stream skip(long n) { @Override public void forEach(Consumer action) { - throw new BingoElasticException("forEach() operation on this stream isn't implemented"); + this.collect(Collectors.toList()).forEach(action); } @Override public void forEachOrdered(Consumer action) { - throw new BingoElasticException("forEachOrdered() operation on this stream isn't implemented"); + this.forEach(action); } @Override public Object[] toArray() { - throw new BingoElasticException("toArray() operation on this stream isn't implemented"); + return this.collect(Collectors.toList()).toArray(); } @Override public A[] toArray(IntFunction generator) { - throw new BingoElasticException("toArray() operation on this stream isn't implemented"); + throw new BingoElasticException("toArray(IntFunction generator) operation on this stream isn't implemented"); } @Override