From b4e53203fbbc91fa4b8297406b10133eb40c812a Mon Sep 17 00:00:00 2001 From: NebelNidas Date: Tue, 10 Oct 2023 20:22:08 +0200 Subject: [PATCH] Make `MappingWriter#create` return null instead of throwing an exception --- src/main/java/net/fabricmc/mappingio/MappingWriter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/fabricmc/mappingio/MappingWriter.java b/src/main/java/net/fabricmc/mappingio/MappingWriter.java index 736f1a2f..8e3b8597 100644 --- a/src/main/java/net/fabricmc/mappingio/MappingWriter.java +++ b/src/main/java/net/fabricmc/mappingio/MappingWriter.java @@ -30,17 +30,19 @@ import net.fabricmc.mappingio.format.tiny.Tiny2FileWriter; public interface MappingWriter extends Closeable, MappingVisitor { + @Nullable static MappingWriter create(Path file, MappingFormat format) throws IOException { if (format.hasSingleFile()) { return create(Files.newBufferedWriter(file), format); } else { switch (format) { case ENIGMA_DIR: return new EnigmaDirWriter(file, true); - default: throw new UnsupportedOperationException("format "+format+" is not implemented"); + default: return null; } } } + @Nullable static MappingWriter create(Writer writer, MappingFormat format) throws IOException { if (!format.hasSingleFile()) throw new IllegalArgumentException("format "+format+" is not applicable to a single writer"); @@ -49,7 +51,7 @@ static MappingWriter create(Writer writer, MappingFormat format) throws IOExcept case TINY_2_FILE: return new Tiny2FileWriter(writer, false); case ENIGMA_FILE: return new EnigmaFileWriter(writer); case PROGUARD_FILE: return new ProGuardFileWriter(writer); - default: throw new UnsupportedOperationException("format "+format+" is not implemented"); + default: return null; } }