我的POJO如下
class EventUser {
private id;
private userId;
private eventId;
}
我按如下方式检索 EventUser 对象:
List<EventUser> eventUsers = eventUserRepository.findByUserId(userId);
说'eventUsers'如下:
[
{"id":"id200","userId":"001","eventId":"1010"},
{"id":"id101","userId":"001","eventId":"4212"},
{"id":"id402","userId":"001","eventId":"1221"},
{"id":"id301","userId":"001","eventId":"2423"},
{"id":"id701","userId":"001","eventId":"5423"},
{"id":"id601","userId":"001","eventId":"7423"}
]
使用流,而不使用任何中间变量,如何在给定的 EventUser.id 之后过滤和收集事件:例如:
List<EventUser> filteredByOffSet = eventUsers.stream.SOMEFILTER_AND_COLLECT("id301");
结果应该是:
[{"id":"id301","userId":"001","eventId":"2423"},
{"id":"id701","userId":"001","eventId":"5423"},
{"id":"id601","userId":"001","eventId":"7423"}]
郎朗坤
万千封印
守候你守候我
相关分类