blob: 6335974b1dea2a72abbbf74145f8cc946069edef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package cuchaz.enigma.convert;
import java.util.Collection;
import java.util.Set;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import cuchaz.enigma.mapping.ClassEntry;
import cuchaz.enigma.mapping.FieldEntry;
public class FieldMatches {
private BiMap<FieldEntry,FieldEntry> m_matches;
private Multimap<ClassEntry,FieldEntry> m_unmatchedSourceFields;
private Multimap<ClassEntry,FieldEntry> m_unmatchedDestFields;
public FieldMatches() {
m_matches = HashBiMap.create();
m_unmatchedSourceFields = HashMultimap.create();
m_unmatchedDestFields = HashMultimap.create();
}
public void addMatch(FieldEntry srcField, FieldEntry destField) {
m_matches.put(srcField, destField);
}
public void addUnmatchedSourceField(FieldEntry fieldEntry) {
m_unmatchedSourceFields.put(fieldEntry.getClassEntry(), fieldEntry);
}
public void addUnmatchedSourceFields(Iterable<FieldEntry> fieldEntries) {
for (FieldEntry fieldEntry : fieldEntries) {
addUnmatchedSourceField(fieldEntry);
}
}
public void addUnmatchedDestField(FieldEntry fieldEntry) {
m_unmatchedDestFields.put(fieldEntry.getClassEntry(), fieldEntry);
}
public void addUnmatchedDestFields(Iterable<FieldEntry> fieldEntries) {
for (FieldEntry fieldEntry : fieldEntries) {
addUnmatchedDestField(fieldEntry);
}
}
public Set<ClassEntry> getSourceClassesWithUnmatchedFields() {
return m_unmatchedSourceFields.keySet();
}
public Collection<FieldEntry> getUnmatchedSourceFields() {
return m_unmatchedSourceFields.values();
}
public Collection<FieldEntry> getUnmatchedSourceFields(ClassEntry sourceClass) {
return m_unmatchedSourceFields.get(sourceClass);
}
public Collection<FieldEntry> getUnmatchedDestFields() {
return m_unmatchedDestFields.values();
}
public Collection<FieldEntry> getUnmatchedDestFields(ClassEntry sourceClass) {
return m_unmatchedDestFields.get(sourceClass);
}
public BiMap<FieldEntry,FieldEntry> matches() {
return m_matches;
}
public boolean isDestMatched(FieldEntry destFieldEntry) {
return m_matches.containsValue(destFieldEntry);
}
public void makeMatch(FieldEntry sourceField, FieldEntry destField) {
m_unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField);
m_unmatchedDestFields.remove(destField.getClassEntry(), destField);
m_matches.put(sourceField, destField);
}
}
|