private static List<Project> collectProjects(String loginId, User user, String[] groupNames) { List<Project> projectCollection = new ArrayList<>(); // collect all projects that are included in the project groups. for (String group : groupNames) { switch (group) { case "own": addProjectNotDupped(projectCollection, Project.findProjectsCreatedByUser(loginId, null)); break; case "member": addProjectNotDupped(projectCollection, Project.findProjectsJustMemberAndNotOwner(user)); break; case "watching": addProjectNotDupped(projectCollection, user.getWatchingProjects()); break; } } return projectCollection; }