aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/zwirn/Zwirn.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea/zwirn/Zwirn.java')
-rw-r--r--src/main/java/moe/nea/zwirn/Zwirn.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/zwirn/Zwirn.java b/src/main/java/moe/nea/zwirn/Zwirn.java
index 3612007..b3a4956 100644
--- a/src/main/java/moe/nea/zwirn/Zwirn.java
+++ b/src/main/java/moe/nea/zwirn/Zwirn.java
@@ -21,6 +21,24 @@ public class Zwirn {
return new TinyMerger(base, overlay, sharedNamespace).merge();
}
+
+ public record RenameCommand(
+ String oldNamespaceName,
+ String newNamespaceName
+ ) {
+ }
+
+ public static @NotNull TinyFile renameNamespaces(
+ @NotNull TinyFile tinyFile,
+ @NotNull List<@NotNull RenameCommand> newNamespaceOrder
+ ) {
+ for (var renameCommand : newNamespaceOrder) {
+ if (!tinyFile.getHeader().getNamespaces().contains(renameCommand.oldNamespaceName()))
+ throw new IllegalArgumentException("Old namespace " + renameCommand.oldNamespaceName() + " not found");
+ }
+ return new RenameTask(tinyFile, newNamespaceOrder).rename();
+ }
+
public static @NotNull TinyFile enrichSeargeWithMCP(@NotNull TinyFile searge, @NotNull Path mcpArchiveRoot) throws IOException {
if (!searge.getHeader().getNamespaces().equals(Arrays.asList("left", "right")))
throw new IllegalArgumentException("Searge namespaces need to be left and right");