Hello What am I doing wrong here
I want to get the foundation Id , if its not present then get Insurance Type.. the code snippets are pasted below .. but I get an error at the orElse part I even tried orElseGet() ...It says "target type of Lambda must be an interface"..
String type = getFoundationId(companyInsurances).orElse(()->getInsuranceType(insurance, companyInsurances));
…
private Optional<String> getInsuranceType(Insurance insurance, List<CompanyInsurance> companyInsurances) {
return InsurancePeriodHelper.findFirstCompanyInsuranceOfType(companyInsurances, CompanyInsuranceType.POLICY_HOLDER.getValue())
.map(companyInsurance-> insurance.getProduct());
}
private Optional<String> getFoundationId(List<CompanyInsurance> companyInsurances) {
return InsurancePeriodHelper.findFirstCompanyInsuranceOfType(companyInsurances, CompanyInsuranceType.FOUNDATION.getValue())
.map(companyInsurance -> companyInsurance.getCompany().getFoundationIdentifier().toString());
}