public Map<String, List<CRPipeline>> groupPipelinesByGroupName(Collection<CRPipeline> pipelines) { Map<String, List<CRPipeline>> map = new HashMap<>(); for (CRPipeline pipe : pipelines) { String key = pipe.getGroupName(); if (map.get(key) == null) { map.put(key, new ArrayList<CRPipeline>()); } map.get(key).add(pipe); } return map; }