class CompetitionInitialiser {

    public Competition initialiseFinanceTypes(Competition competition) {
        if (competition.getFundingType() == null) {
            return competition;
        }
        List<FinanceRowType> types;
        switch (competition.getFundingType()) {
            case LOAN:
                types = loanFinanceTypes();
                break;
            case PROCUREMENT:
                types = procurementFinanceTypes();
                break;
            case KTP:
                types = ktpFinanceTypes();
                break;
            case GRANT:
            case INVESTOR_PARTNERSHIPS:
                types = defaultFinanceTypes();
                break;
            default:
                throw new IllegalArgumentException("Unrecognised funding type when initialising competition.");
        }
        IntStream.range(0, types.size()).forEach(i ->
            competition.getCompetitionFinanceRowTypes().add(
                    competitionFinanceRowsTypesRepository.save(
                            new CompetitionFinanceRowTypes(competition, types.get(i), i)))
        );
        return competition;
    }

}