Changes between Version 1 and Version 2 of Ticket #11390, comment 132
- Timestamp:
- 2016-07-23T22:43:35+02:00 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #11390, comment 132
v1 v2 4 4 5 5 I prefer having a new utils class for all that stream stuff. The current `Utils` class is pretty long already. 6 7 I'd also deprecate the find() methods. You should rewrite your code as: 8 {{{ 9 #!java 10 Optional<?> item = list.stream().filter(...).findFirst(); 11 if (!item.isPresent()) { 12 // handle error. 13 } 14 }}} 15 16 It gives programmers the ability to search whatever they prefer (`findFirst()`, `findAny()` or the reduce((a, b) -> throw new Exception()) hack to get exactly one element) and to do a nicer error handling using `orElseThrow`, `orElseGet` or other methods. It would remove a lot of != null checks. And since those methods depend on JOSM predicate, we need to deprecate them any way.


