Skip to content

Commit 690dc02

Browse files
committed
Deprecate MongoIterable#forEach(Block<? super TResult> block)
With the addition of the default method Iterable#forEach(Consumer)} in Java 8, MongoIterable#forEach(Block<? super TResult> block) results in an error at the point of call of forEach when using a lambda, which can only be resolved by casting to either Block or Consumer. Rather than keep that unfriendly API, we deprecate MongoIterable#forEach so that it can be removed in the next major release of the driver (which will required Java 8). JAVA-3046
1 parent ef1c166 commit 690dc02

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

driver-sync/src/main/com/mongodb/client/MongoIterable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.mongodb.lang.Nullable;
2222

2323
import java.util.Collection;
24+
import java.util.function.Consumer;
2425

2526
/**
2627
*The MongoIterable is the results from an operation, such as a query.
@@ -56,7 +57,9 @@ public interface MongoIterable<TResult> extends Iterable<TResult> {
5657
* <p>Similar to {@code map} but the function is fully encapsulated with no returned result.</p>
5758
*
5859
* @param block the block to apply to each document of type T.
60+
* @deprecated Prefer {@link Iterable#forEach(Consumer)}, which was added in Java 8
5961
*/
62+
@Deprecated
6063
void forEach(Block<? super TResult> block);
6164

6265
/**

0 commit comments

Comments
 (0)