class FinanceReadOnlyViewModelPopulator extends AsyncAdaptor {

    public FinanceReadOnlyViewModel populate(ApplicationReadOnlyData data) {
        CompetitionResource competition = data.getCompetition();
        ApplicationResource application = data.getApplication();
        Future<SectionResource> financeSection = async(() -> sectionRestService.getSectionsByCompetitionIdAndType(competition.getId(), SectionType.FINANCE).getSuccess().get(0));
        Future<ApplicationFinanceSummaryViewModel> applicationFinanceSummaryViewModel = async(() -> applicationFinanceSummaryViewModelPopulator.populate(application.getId(), data.getUser()));
        Future<ApplicationResearchParticipationViewModel> applicationResearchParticipationViewModel = async(() -> applicationResearchParticipationViewModelPopulator.populate(application.getId()));
        Future<ApplicationFundingBreakdownViewModel> applicationFundingBreakdownViewModel = async(() -> applicationFundingBreakdownViewModelPopulator.populate(application.getId(), data.getUser()));

        return new FinanceReadOnlyViewModel(
                application.getId(),
                competition.isFullyFunded(),
                resolve(financeSection).getId(),
                resolve(applicationFinanceSummaryViewModel),
                resolve(applicationResearchParticipationViewModel),
                resolve(applicationFundingBreakdownViewModel),
                application.isCollaborativeProject(),
                competition.isKtp());
    }

    public  FinanceReadOnlyViewModelPopulator(ApplicationFinanceSummaryViewModelPopulator applicationFinanceSummaryViewModelPopulator,
                                             ApplicationFundingBreakdownViewModelPopulator applicationFundingBreakdownViewModelPopulator,
                                             ApplicationResearchParticipationViewModelPopulator applicationResearchParticipationViewModelPopulator,
                                             SectionRestService sectionRestService);

}