Skip to content

Commit

Permalink
epam#1826 - forEach, toArray, findFirst methods for ElasticStream
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkaminski committed Aug 7, 2024
1 parent 4927ba5 commit 00a2e3a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -262,12 +263,12 @@ public boolean noneMatch(Predicate<? super T> predicate) {

@Override
public Optional<T> findFirst() {
throw new BingoElasticException("findFirst() operation on this stream isn't implemented");
return this.limit(1).collect(Collectors.toList()).stream().findFirst();
}

@Override
public Optional<T> findAny() {
throw new BingoElasticException("findAny() operation on this stream isn't implemented");
return findFirst();
}

@Override
Expand Down Expand Up @@ -342,22 +343,22 @@ public Stream<T> skip(long n) {

@Override
public void forEach(Consumer<? super T> action) {
throw new BingoElasticException("forEach() operation on this stream isn't implemented");
this.collect(Collectors.toList()).forEach(action);
}

@Override
public void forEachOrdered(Consumer<? super T> 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> A[] toArray(IntFunction<A[]> generator) {
throw new BingoElasticException("toArray() operation on this stream isn't implemented");
throw new BingoElasticException("toArray(IntFunction<A[]> generator) operation on this stream isn't implemented");
}

@Override
Expand Down

0 comments on commit 00a2e3a

Please sign in to comment.