GroupedPushResult (@NotNull Map<GitRepository, GitPushRepoResult> results) { Map<GitRepository, GitPushRepoResult> successful = new HashMap<>(); Map<GitRepository, GitPushRepoResult> rejected = new HashMap<>(); Map<GitRepository, GitPushRepoResult> customRejected = new HashMap<>(); Map<GitRepository, GitPushRepoResult> errors = new HashMap<>(); for (Map.Entry<GitRepository, GitPushRepoResult> entry : results.entrySet()) { GitRepository repository = entry.getKey(); GitPushRepoResult result = entry.getValue(); Map<GitRepository, GitPushRepoResult> map = switch (result.getType()) { case REJECTED_NO_FF -> rejected; case ERROR -> errors; case REJECTED_STALE_INFO, REJECTED_OTHER -> customRejected; default -> successful; }; map.put(repository, result); } return new GroupedPushResult(successful, errors, rejected, customRejected); }