allow mass-merging of bundles

This commit is contained in:
moehreag 2024-07-01 02:05:21 +02:00
parent 84fd29a7f4
commit 9a1f48345f

View file

@ -31,14 +31,15 @@ public record MappingBundle(List<MappingData> data, List<DocumentationData> docu
return list; return list;
} }
public static MappingBundle merge(MappingBundle a, MappingBundle b) { public static MappingBundle merge(MappingBundle... bundles) {
List<MappingData> mergedData = new ArrayList<>(); List<MappingData> mergedData = new ArrayList<>();
mergedData.addAll(a.data());
mergedData.addAll(b.data());
List<DocumentationData> mergedDocs = new ArrayList<>(); List<DocumentationData> mergedDocs = new ArrayList<>();
mergedDocs.addAll(a.documentation());
mergedDocs.addAll(b.documentation()); for (MappingBundle bundle : bundles) {
mergedData.addAll(bundle.data());
mergedDocs.addAll(bundle.documentation());
}
return new MappingBundle(mergedData, mergedDocs); return new MappingBundle(mergedData, mergedDocs);
} }
@ -68,14 +69,6 @@ public record MappingBundle(List<MappingData> data, List<DocumentationData> docu
} }
public MappingData forNamespaces(String src, String dst) { public MappingData forNamespaces(String src, String dst) {
/*List<MappingData> matching = new ArrayList<>();
for (MappingData datum : data) {
if (!datum.dstNamespace().equals(src) && !datum.srcNamespace().equals(dst)) { // cut the graph so it has new ends
matching.add(datum);
}
}
return new MappingBundle(matching, documentation).flatten(src, dst);*/
return flatten(src, dst); return flatten(src, dst);
} }