summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/convert/MatchesWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/convert/MatchesWriter.java')
-rw-r--r--src/cuchaz/enigma/convert/MatchesWriter.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/convert/MatchesWriter.java b/src/cuchaz/enigma/convert/MatchesWriter.java
new file mode 100644
index 0000000..49ffb6d
--- /dev/null
+++ b/src/cuchaz/enigma/convert/MatchesWriter.java
@@ -0,0 +1,41 @@
1package cuchaz.enigma.convert;
2
3import java.io.File;
4import java.io.FileWriter;
5import java.io.IOException;
6
7import cuchaz.enigma.mapping.ClassEntry;
8
9
10public class MatchesWriter {
11
12 public static void write(Matches matches, File file)
13 throws IOException {
14 try (FileWriter out = new FileWriter(file)) {
15 for (ClassMatch match : matches) {
16 writeMatch(out, match);
17 }
18 }
19 }
20
21 private static void writeMatch(FileWriter out, ClassMatch match)
22 throws IOException {
23 writeClasses(out, match.sourceClasses);
24 out.write(":");
25 writeClasses(out, match.destClasses);
26 out.write("\n");
27 }
28
29 private static void writeClasses(FileWriter out, Iterable<ClassEntry> classes)
30 throws IOException {
31 boolean isFirst = true;
32 for (ClassEntry entry : classes) {
33 if (isFirst) {
34 isFirst = false;
35 } else {
36 out.write(",");
37 }
38 out.write(entry.toString());
39 }
40 }
41}