diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/FieldMatches.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/FieldMatches.java | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/FieldMatches.java b/src/main/java/cuchaz/enigma/convert/FieldMatches.java index 0899cd2..236cd4d 100644 --- a/src/main/java/cuchaz/enigma/convert/FieldMatches.java +++ b/src/main/java/cuchaz/enigma/convert/FieldMatches.java | |||
| @@ -21,29 +21,29 @@ import cuchaz.enigma.mapping.FieldEntry; | |||
| 21 | 21 | ||
| 22 | public class FieldMatches { | 22 | public class FieldMatches { |
| 23 | 23 | ||
| 24 | private BiMap<FieldEntry, FieldEntry> m_matches; | 24 | private BiMap<FieldEntry, FieldEntry> matches; |
| 25 | private Multimap<ClassEntry, FieldEntry> m_matchedSourceFields; | 25 | private Multimap<ClassEntry, FieldEntry> matchedSourceFields; |
| 26 | private Multimap<ClassEntry, FieldEntry> m_unmatchedSourceFields; | 26 | private Multimap<ClassEntry, FieldEntry> unmatchedSourceFields; |
| 27 | private Multimap<ClassEntry, FieldEntry> m_unmatchedDestFields; | 27 | private Multimap<ClassEntry, FieldEntry> unmatchedDestFields; |
| 28 | private Multimap<ClassEntry, FieldEntry> m_unmatchableSourceFields; | 28 | private Multimap<ClassEntry, FieldEntry> unmatchableSourceFields; |
| 29 | 29 | ||
| 30 | public FieldMatches() { | 30 | public FieldMatches() { |
| 31 | m_matches = HashBiMap.create(); | 31 | matches = HashBiMap.create(); |
| 32 | m_matchedSourceFields = HashMultimap.create(); | 32 | matchedSourceFields = HashMultimap.create(); |
| 33 | m_unmatchedSourceFields = HashMultimap.create(); | 33 | unmatchedSourceFields = HashMultimap.create(); |
| 34 | m_unmatchedDestFields = HashMultimap.create(); | 34 | unmatchedDestFields = HashMultimap.create(); |
| 35 | m_unmatchableSourceFields = HashMultimap.create(); | 35 | unmatchableSourceFields = HashMultimap.create(); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public void addMatch(FieldEntry srcField, FieldEntry destField) { | 38 | public void addMatch(FieldEntry srcField, FieldEntry destField) { |
| 39 | boolean wasAdded = m_matches.put(srcField, destField) == null; | 39 | boolean wasAdded = matches.put(srcField, destField) == null; |
| 40 | assert (wasAdded); | 40 | assert (wasAdded); |
| 41 | wasAdded = m_matchedSourceFields.put(srcField.getClassEntry(), srcField); | 41 | wasAdded = matchedSourceFields.put(srcField.getClassEntry(), srcField); |
| 42 | assert (wasAdded); | 42 | assert (wasAdded); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | public void addUnmatchedSourceField(FieldEntry fieldEntry) { | 45 | public void addUnmatchedSourceField(FieldEntry fieldEntry) { |
| 46 | boolean wasAdded = m_unmatchedSourceFields.put(fieldEntry.getClassEntry(), fieldEntry); | 46 | boolean wasAdded = unmatchedSourceFields.put(fieldEntry.getClassEntry(), fieldEntry); |
| 47 | assert (wasAdded); | 47 | assert (wasAdded); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| @@ -54,7 +54,7 @@ public class FieldMatches { | |||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | public void addUnmatchedDestField(FieldEntry fieldEntry) { | 56 | public void addUnmatchedDestField(FieldEntry fieldEntry) { |
| 57 | boolean wasAdded = m_unmatchedDestFields.put(fieldEntry.getClassEntry(), fieldEntry); | 57 | boolean wasAdded = unmatchedDestFields.put(fieldEntry.getClassEntry(), fieldEntry); |
| 58 | assert (wasAdded); | 58 | assert (wasAdded); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -65,78 +65,78 @@ public class FieldMatches { | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | public void addUnmatchableSourceField(FieldEntry sourceField) { | 67 | public void addUnmatchableSourceField(FieldEntry sourceField) { |
| 68 | boolean wasAdded = m_unmatchableSourceFields.put(sourceField.getClassEntry(), sourceField); | 68 | boolean wasAdded = unmatchableSourceFields.put(sourceField.getClassEntry(), sourceField); |
| 69 | assert (wasAdded); | 69 | assert (wasAdded); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | public Set<ClassEntry> getSourceClassesWithUnmatchedFields() { | 72 | public Set<ClassEntry> getSourceClassesWithUnmatchedFields() { |
| 73 | return m_unmatchedSourceFields.keySet(); | 73 | return unmatchedSourceFields.keySet(); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | public Collection<ClassEntry> getSourceClassesWithoutUnmatchedFields() { | 76 | public Collection<ClassEntry> getSourceClassesWithoutUnmatchedFields() { |
| 77 | Set<ClassEntry> out = Sets.newHashSet(); | 77 | Set<ClassEntry> out = Sets.newHashSet(); |
| 78 | out.addAll(m_matchedSourceFields.keySet()); | 78 | out.addAll(matchedSourceFields.keySet()); |
| 79 | out.removeAll(m_unmatchedSourceFields.keySet()); | 79 | out.removeAll(unmatchedSourceFields.keySet()); |
| 80 | return out; | 80 | return out; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | public Collection<FieldEntry> getUnmatchedSourceFields() { | 83 | public Collection<FieldEntry> getUnmatchedSourceFields() { |
| 84 | return m_unmatchedSourceFields.values(); | 84 | return unmatchedSourceFields.values(); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | public Collection<FieldEntry> getUnmatchedSourceFields(ClassEntry sourceClass) { | 87 | public Collection<FieldEntry> getUnmatchedSourceFields(ClassEntry sourceClass) { |
| 88 | return m_unmatchedSourceFields.get(sourceClass); | 88 | return unmatchedSourceFields.get(sourceClass); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | public Collection<FieldEntry> getUnmatchedDestFields() { | 91 | public Collection<FieldEntry> getUnmatchedDestFields() { |
| 92 | return m_unmatchedDestFields.values(); | 92 | return unmatchedDestFields.values(); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | public Collection<FieldEntry> getUnmatchedDestFields(ClassEntry destClass) { | 95 | public Collection<FieldEntry> getUnmatchedDestFields(ClassEntry destClass) { |
| 96 | return m_unmatchedDestFields.get(destClass); | 96 | return unmatchedDestFields.get(destClass); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | public Collection<FieldEntry> getUnmatchableSourceFields() { | 99 | public Collection<FieldEntry> getUnmatchableSourceFields() { |
| 100 | return m_unmatchableSourceFields.values(); | 100 | return unmatchableSourceFields.values(); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | public boolean hasSource(FieldEntry fieldEntry) { | 103 | public boolean hasSource(FieldEntry fieldEntry) { |
| 104 | return m_matches.containsKey(fieldEntry) || m_unmatchedSourceFields.containsValue(fieldEntry); | 104 | return matches.containsKey(fieldEntry) || unmatchedSourceFields.containsValue(fieldEntry); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | public boolean hasDest(FieldEntry fieldEntry) { | 107 | public boolean hasDest(FieldEntry fieldEntry) { |
| 108 | return m_matches.containsValue(fieldEntry) || m_unmatchedDestFields.containsValue(fieldEntry); | 108 | return matches.containsValue(fieldEntry) || unmatchedDestFields.containsValue(fieldEntry); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | public BiMap<FieldEntry, FieldEntry> matches() { | 111 | public BiMap<FieldEntry, FieldEntry> matches() { |
| 112 | return m_matches; | 112 | return matches; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | public boolean isMatchedSourceField(FieldEntry sourceField) { | 115 | public boolean isMatchedSourceField(FieldEntry sourceField) { |
| 116 | return m_matches.containsKey(sourceField); | 116 | return matches.containsKey(sourceField); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | public boolean isMatchedDestField(FieldEntry destField) { | 119 | public boolean isMatchedDestField(FieldEntry destField) { |
| 120 | return m_matches.containsValue(destField); | 120 | return matches.containsValue(destField); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | public void makeMatch(FieldEntry sourceField, FieldEntry destField) { | 123 | public void makeMatch(FieldEntry sourceField, FieldEntry destField) { |
| 124 | boolean wasRemoved = m_unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField); | 124 | boolean wasRemoved = unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField); |
| 125 | assert (wasRemoved); | 125 | assert (wasRemoved); |
| 126 | wasRemoved = m_unmatchedDestFields.remove(destField.getClassEntry(), destField); | 126 | wasRemoved = unmatchedDestFields.remove(destField.getClassEntry(), destField); |
| 127 | assert (wasRemoved); | 127 | assert (wasRemoved); |
| 128 | addMatch(sourceField, destField); | 128 | addMatch(sourceField, destField); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | public boolean isMatched(FieldEntry sourceField, FieldEntry destField) { | 131 | public boolean isMatched(FieldEntry sourceField, FieldEntry destField) { |
| 132 | FieldEntry match = m_matches.get(sourceField); | 132 | FieldEntry match = matches.get(sourceField); |
| 133 | return match != null && match.equals(destField); | 133 | return match != null && match.equals(destField); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | public void unmakeMatch(FieldEntry sourceField, FieldEntry destField) { | 136 | public void unmakeMatch(FieldEntry sourceField, FieldEntry destField) { |
| 137 | boolean wasRemoved = m_matches.remove(sourceField) != null; | 137 | boolean wasRemoved = matches.remove(sourceField) != null; |
| 138 | assert (wasRemoved); | 138 | assert (wasRemoved); |
| 139 | wasRemoved = m_matchedSourceFields.remove(sourceField.getClassEntry(), sourceField); | 139 | wasRemoved = matchedSourceFields.remove(sourceField.getClassEntry(), sourceField); |
| 140 | assert (wasRemoved); | 140 | assert (wasRemoved); |
| 141 | addUnmatchedSourceField(sourceField); | 141 | addUnmatchedSourceField(sourceField); |
| 142 | addUnmatchedDestField(destField); | 142 | addUnmatchedDestField(destField); |
| @@ -144,7 +144,7 @@ public class FieldMatches { | |||
| 144 | 144 | ||
| 145 | public void makeSourceUnmatchable(FieldEntry sourceField) { | 145 | public void makeSourceUnmatchable(FieldEntry sourceField) { |
| 146 | assert (!isMatchedSourceField(sourceField)); | 146 | assert (!isMatchedSourceField(sourceField)); |
| 147 | boolean wasRemoved = m_unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField); | 147 | boolean wasRemoved = unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField); |
| 148 | assert (wasRemoved); | 148 | assert (wasRemoved); |
| 149 | addUnmatchableSourceField(sourceField); | 149 | addUnmatchableSourceField(sourceField); |
| 150 | } | 150 | } |