/** * Convert the subscriptions result set to {@link SubscriptionLightVo} */ private Collection<SubscriptionLightVo> toSubscriptions(final List<Object[]> subscriptions, final Map<Integer, SubscribingProjectVo> projects) { // Prepare the subscriptions container with project name ordering return subscriptions.stream().filter(rs -> projects.containsKey(rs[1])).map(rs -> { // Build the subscription data final SubscriptionLightVo vo = new SubscriptionLightVo(); vo.setId((Integer) rs[0]); vo.setProject((Integer) rs[1]); vo.setNode((String) rs[2]); return vo; }).collect( () -> new TreeSet<>((o1, o2) -> (projects.get(o1.getProject()).getName() + "," + o1.getId()) .compareToIgnoreCase(projects.get(o2.getProject()).getName() + "," + o2.getId())), TreeSet::add, TreeSet::addAll); }