Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

package gov.va.med.ewv.util;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

import gov.va.med.domain.ewv.EwvAmbulanceInfo5010;
import gov.va.med.domain.ewv.EwvClaimOhis;
import gov.va.med.domain.ewv.EwvClaims;
import gov.va.med.domain.ewv.EwvServiceLineOhiAdjtmts;
import gov.va.med.domain.ewv.EwvServiceLineOhis;
import gov.va.med.domain.ewv.EwvServiceLines;
import gov.va.med.domain.ewv.EwvServiceLinesDrugs;
import gov.va.med.domain.ewv.EwvSlProvider;
import gov.va.med.domain.ewv.EwvSvcLineDme;
import gov.va.med.domain.ewv.EwvSvcLineTeeth;
import static gov.va.med.ewv.util.SetToSortedList.*; // where overloaded EwvNullsLastComparator::compare are from
import java.util.function.*;

// Compare to non-generic EwvSetToNullsLastList
public class EwvNullsLastSortedList {
// Extract partially sorted lists (sorted good enough for highlighting)
// Returns an empty list in case of null obj or set
// Each function performs a unique extraction from its base type
// Since there are more than one, they cannot be overloaded on the parameter obj.

// Using a generic function, we make the implementation consistent
public static <T, R> List<R> getSortedList(T obj, Function<T, Set<R>> getSet, Comparator<R> compare) {
if (obj == null) {
// We can hardly extract a set from a null object.
// We could just return null, and let the caller handle it,
// but we can return an empty list, which is easier to handle.
return Collections.<R>emptyList();
}
Set<R> set = getSet.apply(obj);
// Now, set could also be null, but toSortedList will also return an empty list in that case.
return toSortedList(set, compare);
}

// From EwvClaims
public static List<EwvServiceLines> getEwvServiceLinesList(EwvClaims obj) {
return getSortedList(obj, EwvClaims::getEwvServiceLineses, EwvNullsLastComparator::compare);
}

public static List<EwvClaimOhis> getEwvClaimOhisList(EwvClaims obj) {
return getSortedList(obj, EwvClaims::getEwvClaimOhises, EwvNullsLastComparator::compare);
}

// From EwvServiceLines
public static List<EwvSvcLineDme> getEwvSvcLineDmeList(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvSvcLineDmes, EwvNullsLastComparator::compare);
}

public static List<EwvSlProvider> getEwvSlProviderList(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvSlProviders, EwvNullsLastComparator::compare);
}

public static List<EwvServiceLineOhis> getEwvServiceLineOhisList(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvServiceLineOhises, EwvNullsLastComparator::compare);
}

public static List<EwvSvcLineTeeth> getEwvSvcLineTeethList(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvSvcLineTeeths, EwvNullsLastComparator::compare);
}

public static List<EwvAmbulanceInfo5010> getEwvAmbulanceInfo5010List(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvAmbulanceInfo5010s, EwvNullsLastComparator::compare);
}

public static List<EwvServiceLinesDrugs> getEwvServiceLinesDrugsList(EwvServiceLines obj) {
return getSortedList(obj, EwvServiceLines::getEwvServiceLinesDrugses, EwvNullsLastComparator::compare);
}

// From EwvServiceLineOhis
public static List<EwvServiceLineOhiAdjtmts> getEwvServiceLineOhiAdjtmtsList(EwvServiceLineOhis obj) {
return getSortedList(obj, EwvServiceLineOhis::getEwvServiceLineOhiAdjtmtses, EwvNullsLastComparator::compare);
}

}