Skip to content

Commit

Permalink
Return null when no format reader/writer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed Oct 7, 2023
1 parent ab10550 commit 43749a1
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.nio.file.Path;
import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.MappingWriter;
import net.fabricmc.mappingio.format.enigma.EnigmaDirReader;
Expand Down Expand Up @@ -180,6 +182,7 @@ public String getGlobPattern() {
return "*."+fileExt;
}

@Nullable
public MappingWriter newWriter(Path path) throws IOException {
Objects.requireNonNull(path, "path must not be null");

Expand All @@ -188,11 +191,12 @@ public MappingWriter newWriter(Path path) throws IOException {
} else {
switch (this) {
case ENIGMA_DIR: return new EnigmaDirWriter(path, true);
default: throw new UnsupportedOperationException("format "+this+" is not implemented");
default: return null;
}
}
}

@Nullable
public MappingWriter newWriter(Writer writer) throws IOException {
if (!hasSingleFile()) throw new IllegalArgumentException("format "+this+" is not applicable to a single writer");
Objects.requireNonNull(writer, "writer must not be null");
Expand All @@ -202,7 +206,7 @@ public MappingWriter newWriter(Writer writer) throws IOException {
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 "+this+" is not implemented");
default: return null;
}
}

Expand Down

0 comments on commit 43749a1

Please sign in to comment.