Add resource sorters

This commit is contained in:
Grahame Grieve 2020-06-24 13:45:28 +10:00
parent a338a78b0a
commit 7ac714c2b6
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package org.hl7.fhir.r5.utils;
import java.util.Comparator;
import org.hl7.fhir.r5.model.CanonicalResource;
public class ResourceSorters {
public static class CanonicalResourceSortByUrl implements Comparator<CanonicalResource> {
@Override
public int compare(CanonicalResource arg0, CanonicalResource arg1) {
return arg0.getUrl().compareTo(arg1.getUrl());
}
}
public static class CanonicalResourceSortByTypeId implements Comparator<CanonicalResource> {
@Override
public int compare(CanonicalResource arg0, CanonicalResource arg1) {
int ret = arg0.fhirType().compareTo(arg1.fhirType());
if (ret == 0) {
ret = arg0.getId().compareTo(arg1.getId());
}
return ret;
}
}
}