class GrantTransferDetailsReadOnlyPopulator implements QuestionReadOnlyViewModelPopulator<GrantTransferDetailsReadOnlyViewModel> {

    @Override
    public GrantTransferDetailsReadOnlyViewModel populate(CompetitionResource competition, QuestionResource question, ApplicationReadOnlyData data, ApplicationReadOnlySettings settings) {
        Optional<EuGrantTransferResource> grantTransferResource = grantTransferRestService.findDetailsByApplicationId(data.getApplication().getId()).getOptionalSuccessObject();
        if (grantTransferResource.isPresent()) {
            return new GrantTransferDetailsReadOnlyViewModel(
                    data,
                    question,
                    grantTransferResource.get().getGrantAgreementNumber(),
                    grantTransferResource.get().getParticipantId(),
                    grantTransferResource.get().getProjectName(),
                    grantTransferResource.get().getProjectStartDate(),
                    grantTransferResource.get().getProjectEndDate(),
                    grantTransferResource.get().getFundingContribution(),
                    grantTransferResource.get().getProjectCoordinator(),
                    grantTransferResource
                            .map(EuGrantTransferResource::getActionType)
                            .orElse(null)
            );
        }
        return new GrantTransferDetailsReadOnlyViewModel(data, question);
    }

    public  GrantTransferDetailsReadOnlyPopulator(EuGrantTransferRestService grantTransferRestService);

}