Just to be clear I am not a java developer.
I have java code written for version 1.8. However, the java.util.function is not available in version 1.7 hence I am not able to compile the code. How can I compile\convert the code to make it compatible to version 1.7 compiler?
below is the code
import java.util.*;
import java.util.function.Predicate;
public List<PersonSearchResult> searchPersonListAsPerson( Person bean, short minScore, int maxResults, String cvwName, Person.PersonSource[] sources, Person.PersonAttribute[] attributes) throws MasterDataServiceException {
logServiceBegin(log, "searchPersonListAsPerson");
PersonMapper mapper = new PersonMapper();
List<PersonSearchResult> searchResults = searchForRecordList( mapper, bean, PersonEntityId.getStaticEntType(), minScore, maxResults, cvwName, sources, attributes);
if(searchResults != null && searchResults.size() > 1) {
PersonPredicate pPredicate = new PersonPredicate();
//TODO: Where to get the srccode as per below??
//pPredicate.setSrcCodeToTest("CRDSCNCTP");
//searchResults = searchResults.stream().filter(pPredicate).collect(Collectors.toList());
//TODO: what if there is no result with that src code searchResults will become empty
if(searchResults != null && searchResults.size() > 1){
Collections.sort(searchResults, new Comparator<PersonSearchResult>(){
public int compare(PersonSearchResult a, PersonSearchResult b) {
if(isNullOrEmpty(a.getPerson().getPerAttributesList()) && isNullOrEmpty(b.getPerson().getPerAttributesList())){
return 0;
}else if(isNullOrEmpty(b.getPerson().getPerAttributesList())){
return -1;
}else if(isNullOrEmpty(a.getPerson().getPerAttributesList())){
return 1;
}else{
int comparison = a.getPerson().getPerAttributesList().get(0).getStatus().compareToIgnoreCase(b.getPerson().getPerAttributesList().get(0).getStatus());
return comparison == 0 ? b.getPerson().getPerAttributesList().get(0).getUpdateDate().compareTo(a.getPerson().getPerAttributesList().get(0).getUpdateDate()) : comparison;
}
}
});
}
}
logServiceEnd(log, "searchPersonListAsPerson");
cleanUserCredentials();
return searchResults;
}
private boolean isNullOrEmpty(List<Memperson> list){
return list == null || list.isEmpty();
}
class PersonPredicate implements Predicate<PersonSearchResult>{
String srcCodeToTest;
public boolean test(PersonSearchResult person) {
return srcCodeToTest.equalsIgnoreCase(person.getPerson().getPersonId().getSrcCode());
}
public void setSrcCodeToTest(String srcCodeToTest){
this.srcCodeToTest = srcCodeToTest;
}