if-else condition using java 8 stream [duplicate]
问题 This question already has answers here : How to use if-else logic in Java 8 stream forEach (4 answers) Closed last year . Scenario: There is a situation where I need to set some values to List of objects based on some field condition using the Java 8 streams API. Below is the sample of object User . public class User{ private int id; private String name; private String text; private boolean isActive; } Here is the code I have worked out List<User> users = userDao.getAllByCompanyId(companyId);