fix bug with duplicate value in getResourceNames()

This commit is contained in:
Grahame Grieve 2023-02-06 05:38:02 +11:00
parent 56205ec963
commit 1d4f1e9d90
2 changed files with 5 additions and 4 deletions

View File

@ -37,9 +37,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -560,13 +562,12 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
@Override
public List<String> getResourceNames() {
List<String> result = new ArrayList<String>();
Set<String> result = new HashSet<String>();
for (StructureDefinition sd : listStructures()) {
if (sd.getKind() == StructureDefinitionKind.RESOURCE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION)
result.add(sd.getName());
}
Collections.sort(result);
return result;
return Utilities.sorted(result);
}

View File

@ -1297,7 +1297,7 @@ public class Utilities {
return id.matches("[A-Za-z0-9\\-\\.]{1,64}");
}
public static List<String> sorted(Set<String> set) {
public static List<String> sorted(Collection<String> set) {
List<String> list = new ArrayList<>();
list.addAll(set);
Collections.sort(list);