[JAVA-2010] Support the use of Java 8 lambdas and MongoIterable.forEach() Created: 07/Oct/15 Updated: 22/Oct/18 Resolved: 22/Oct/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | 3.9.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Andre de Frere | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
The drivers forEach method makes the use of lambda forEach ambiguous:
results in the following compile error
Update
|
| Comments |
| Comment by Githook User [ 22/Oct/18 ] |
|
Author: {'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}Message: Override forEach(Consumer<T>) in MongoIterable implementations The implementations of this method now all properly close the
|
| Comment by Liu Bo [ 20/Jan/16 ] |
|
Hi Jeff, my first thought is exactly the same as yours, but experiment passed, and this confuses me. Here is the full code that can compile and run: My environment: |
| Comment by Jeffrey Yemin [ 19/Jan/16 ] |
|
The first (give doc a type) will not work, as it's still an ambiguous method call. But either of the casts will, as that disambiguates the call. |
| Comment by Liu Bo [ 19/Jan/16 ] |
|
I think this breaks the target typing of java lambda expression. I've also met this issue and here is what I've found after trying around: The first one seems using java Iterable's foreach(not the one from MongoIterable), I'm quite new to lambda, hope someone can explain this behavior. My only guess is java native interfaces comes in a higher priority somehow. |