I\'m trying to understand Java 8 streams. I have two classes:
public class UserMeal {
protected final LocalDateTime dateTime;
protected final String
An addition to the solution by @Rafael Teles. The syntactic sugar Collectors.mapping does the same in one step:
//...
List employees = persons.stream()
.filter(p -> p.getLastName().equals("l1"))
.collect(
Collectors.mapping(
p -> new Employee(p.getName(), p.getLastName(), 1000),
Collectors.toList()));
Detailed example can be found here