summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/convert/FieldMatches.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/convert/FieldMatches.java')
-rw-r--r--src/cuchaz/enigma/convert/FieldMatches.java69
1 files changed, 59 insertions, 10 deletions
diff --git a/src/cuchaz/enigma/convert/FieldMatches.java b/src/cuchaz/enigma/convert/FieldMatches.java
index f78a8f5..6335974 100644
--- a/src/cuchaz/enigma/convert/FieldMatches.java
+++ b/src/cuchaz/enigma/convert/FieldMatches.java
@@ -5,7 +5,8 @@ import java.util.Set;
5 5
6import com.google.common.collect.BiMap; 6import com.google.common.collect.BiMap;
7import com.google.common.collect.HashBiMap; 7import com.google.common.collect.HashBiMap;
8import com.google.common.collect.Sets; 8import com.google.common.collect.HashMultimap;
9import com.google.common.collect.Multimap;
9 10
10import cuchaz.enigma.mapping.ClassEntry; 11import cuchaz.enigma.mapping.ClassEntry;
11import cuchaz.enigma.mapping.FieldEntry; 12import cuchaz.enigma.mapping.FieldEntry;
@@ -14,22 +15,70 @@ import cuchaz.enigma.mapping.FieldEntry;
14public class FieldMatches { 15public class FieldMatches {
15 16
16 private BiMap<FieldEntry,FieldEntry> m_matches; 17 private BiMap<FieldEntry,FieldEntry> m_matches;
17 private Set<FieldEntry> m_unmatchedSourceFields; 18 private Multimap<ClassEntry,FieldEntry> m_unmatchedSourceFields;
19 private Multimap<ClassEntry,FieldEntry> m_unmatchedDestFields;
18 20
19 public FieldMatches() { 21 public FieldMatches() {
20 m_matches = HashBiMap.create(); 22 m_matches = HashBiMap.create();
21 m_unmatchedSourceFields = Sets.newHashSet(); 23 m_unmatchedSourceFields = HashMultimap.create();
24 m_unmatchedDestFields = HashMultimap.create();
22 } 25 }
23 26
24 public void addUnmatchedSourceFields(Set<FieldEntry> fieldEntries) { 27 public void addMatch(FieldEntry srcField, FieldEntry destField) {
25 m_unmatchedSourceFields.addAll(fieldEntries); 28 m_matches.put(srcField, destField);
26 } 29 }
27 30
28 public Collection<ClassEntry> getSourceClassesWithUnmatchedFields() { 31 public void addUnmatchedSourceField(FieldEntry fieldEntry) {
29 Set<ClassEntry> classEntries = Sets.newHashSet(); 32 m_unmatchedSourceFields.put(fieldEntry.getClassEntry(), fieldEntry);
30 for (FieldEntry fieldEntry : m_unmatchedSourceFields) { 33 }
31 classEntries.add(fieldEntry.getClassEntry()); 34
35 public void addUnmatchedSourceFields(Iterable<FieldEntry> fieldEntries) {
36 for (FieldEntry fieldEntry : fieldEntries) {
37 addUnmatchedSourceField(fieldEntry);
38 }
39 }
40
41 public void addUnmatchedDestField(FieldEntry fieldEntry) {
42 m_unmatchedDestFields.put(fieldEntry.getClassEntry(), fieldEntry);
43 }
44
45 public void addUnmatchedDestFields(Iterable<FieldEntry> fieldEntries) {
46 for (FieldEntry fieldEntry : fieldEntries) {
47 addUnmatchedDestField(fieldEntry);
32 } 48 }
33 return classEntries; 49 }
50
51 public Set<ClassEntry> getSourceClassesWithUnmatchedFields() {
52 return m_unmatchedSourceFields.keySet();
53 }
54
55 public Collection<FieldEntry> getUnmatchedSourceFields() {
56 return m_unmatchedSourceFields.values();
57 }
58
59 public Collection<FieldEntry> getUnmatchedSourceFields(ClassEntry sourceClass) {
60 return m_unmatchedSourceFields.get(sourceClass);
61 }
62
63 public Collection<FieldEntry> getUnmatchedDestFields() {
64 return m_unmatchedDestFields.values();
65 }
66
67 public Collection<FieldEntry> getUnmatchedDestFields(ClassEntry sourceClass) {
68 return m_unmatchedDestFields.get(sourceClass);
69 }
70
71 public BiMap<FieldEntry,FieldEntry> matches() {
72 return m_matches;
73 }
74
75 public boolean isDestMatched(FieldEntry destFieldEntry) {
76 return m_matches.containsValue(destFieldEntry);
77 }
78
79 public void makeMatch(FieldEntry sourceField, FieldEntry destField) {
80 m_unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField);
81 m_unmatchedDestFields.remove(destField.getClassEntry(), destField);
82 m_matches.put(sourceField, destField);
34 } 83 }
35} 84}