I wonder how to replace this old school for loops with Java Streams:
public Long getStoreid(){
for (PointDto point : tw.getPath().getPoints())) {
for (PointOperationDto operation : point.getOperations()) {
if (operation.isIncluded() {
return point.getStoreId();
}
}
}
}
I need to get storeId in the best possible way.\
UPDATE
After your answers the working version is:
tw.getPath().getPoints().stream()
.filter(point -> point.getOperations().stream().anyMatch(PointOperation::isIncluded))
.map(point::getStoreId)
.findFirst()
.orElse(null);
but now the question is how to use eg. Optional.ofNullable() to prevent NPE error because tw.getPath() can be null