class NonIfsDetailsFormSaver {

    public ServiceResult<Void> save(NonIfsDetailsForm form, CompetitionResource competitionResource) {
        if(!competitionResource.isNonIfs()) {
            return serviceFailure(CommonFailureKeys.ONLY_NON_IFS_COMPETITION_VALID);
        }

        Map<String, GenericMilestoneRowForm> mappedMilestones = createMilestoneMap(form);
        mapFormFields(form, competitionResource);
        return competitionSetupRestService.update(competitionResource).toServiceResult().andOnSuccess(() -> {
            List<MilestoneResource> milestones = getPublicMilestones(competitionResource);
            return competitionSetupMilestoneService.updateMilestonesForCompetition(milestones, mappedMilestones, competitionResource.getId());
        });
    }

}