diff options
| author | 2017-03-07 21:24:39 +0100 | |
|---|---|---|
| committer | 2017-03-07 21:30:02 +0100 | |
| commit | b4aaff683d78ab92b83f3a7257c33b8e27d1affa (patch) | |
| tree | f23c9bb0927d83cc7302881266b7df8fd37959c7 /src/main/java/cuchaz/enigma/convert/ClassMatches.java | |
| parent | Avoid crash of the matcher when the obf name is invalid (set a deob it using ... (diff) | |
| download | enigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.tar.gz enigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.tar.xz enigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.zip | |
Drop unix case style and implement hashCode when equals is overrided
Also update Guava to version 21
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/ClassMatches.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/ClassMatches.java | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/ClassMatches.java b/src/main/java/cuchaz/enigma/convert/ClassMatches.java index 3a25435..431c4f2 100644 --- a/src/main/java/cuchaz/enigma/convert/ClassMatches.java +++ b/src/main/java/cuchaz/enigma/convert/ClassMatches.java | |||
| @@ -22,28 +22,28 @@ import cuchaz.enigma.mapping.ClassEntry; | |||
| 22 | 22 | ||
| 23 | public class ClassMatches implements Iterable<ClassMatch> { | 23 | public class ClassMatches implements Iterable<ClassMatch> { |
| 24 | 24 | ||
| 25 | Collection<ClassMatch> m_matches; | 25 | private Collection<ClassMatch> matches; |
| 26 | Map<ClassEntry, ClassMatch> m_matchesBySource; | 26 | private Map<ClassEntry, ClassMatch> matchesBySource; |
| 27 | Map<ClassEntry, ClassMatch> m_matchesByDest; | 27 | private Map<ClassEntry, ClassMatch> matchesByDest; |
| 28 | BiMap<ClassEntry, ClassEntry> m_uniqueMatches; | 28 | private BiMap<ClassEntry, ClassEntry> uniqueMatches; |
| 29 | Map<ClassEntry, ClassMatch> m_ambiguousMatchesBySource; | 29 | private Map<ClassEntry, ClassMatch> ambiguousMatchesBySource; |
| 30 | Map<ClassEntry, ClassMatch> m_ambiguousMatchesByDest; | 30 | private Map<ClassEntry, ClassMatch> ambiguousMatchesByDest; |
| 31 | Set<ClassEntry> m_unmatchedSourceClasses; | 31 | private Set<ClassEntry> unmatchedSourceClasses; |
| 32 | Set<ClassEntry> m_unmatchedDestClasses; | 32 | private Set<ClassEntry> unmatchedDestClasses; |
| 33 | 33 | ||
| 34 | public ClassMatches() { | 34 | public ClassMatches() { |
| 35 | this(new ArrayList<>()); | 35 | this(new ArrayList<>()); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public ClassMatches(Collection<ClassMatch> matches) { | 38 | public ClassMatches(Collection<ClassMatch> matches) { |
| 39 | m_matches = matches; | 39 | this.matches = matches; |
| 40 | m_matchesBySource = Maps.newHashMap(); | 40 | matchesBySource = Maps.newHashMap(); |
| 41 | m_matchesByDest = Maps.newHashMap(); | 41 | matchesByDest = Maps.newHashMap(); |
| 42 | m_uniqueMatches = HashBiMap.create(); | 42 | uniqueMatches = HashBiMap.create(); |
| 43 | m_ambiguousMatchesBySource = Maps.newHashMap(); | 43 | ambiguousMatchesBySource = Maps.newHashMap(); |
| 44 | m_ambiguousMatchesByDest = Maps.newHashMap(); | 44 | ambiguousMatchesByDest = Maps.newHashMap(); |
| 45 | m_unmatchedSourceClasses = Sets.newHashSet(); | 45 | unmatchedSourceClasses = Sets.newHashSet(); |
| 46 | m_unmatchedDestClasses = Sets.newHashSet(); | 46 | unmatchedDestClasses = Sets.newHashSet(); |
| 47 | 47 | ||
| 48 | for (ClassMatch match : matches) { | 48 | for (ClassMatch match : matches) { |
| 49 | indexMatch(match); | 49 | indexMatch(match); |
| @@ -51,92 +51,92 @@ public class ClassMatches implements Iterable<ClassMatch> { | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | public void add(ClassMatch match) { | 53 | public void add(ClassMatch match) { |
| 54 | m_matches.add(match); | 54 | matches.add(match); |
| 55 | indexMatch(match); | 55 | indexMatch(match); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | public void remove(ClassMatch match) { | 58 | public void remove(ClassMatch match) { |
| 59 | for (ClassEntry sourceClass : match.sourceClasses) { | 59 | for (ClassEntry sourceClass : match.sourceClasses) { |
| 60 | m_matchesBySource.remove(sourceClass); | 60 | matchesBySource.remove(sourceClass); |
| 61 | m_uniqueMatches.remove(sourceClass); | 61 | uniqueMatches.remove(sourceClass); |
| 62 | m_ambiguousMatchesBySource.remove(sourceClass); | 62 | ambiguousMatchesBySource.remove(sourceClass); |
| 63 | m_unmatchedSourceClasses.remove(sourceClass); | 63 | unmatchedSourceClasses.remove(sourceClass); |
| 64 | } | 64 | } |
| 65 | for (ClassEntry destClass : match.destClasses) { | 65 | for (ClassEntry destClass : match.destClasses) { |
| 66 | m_matchesByDest.remove(destClass); | 66 | matchesByDest.remove(destClass); |
| 67 | m_uniqueMatches.inverse().remove(destClass); | 67 | uniqueMatches.inverse().remove(destClass); |
| 68 | m_ambiguousMatchesByDest.remove(destClass); | 68 | ambiguousMatchesByDest.remove(destClass); |
| 69 | m_unmatchedDestClasses.remove(destClass); | 69 | unmatchedDestClasses.remove(destClass); |
| 70 | } | 70 | } |
| 71 | m_matches.remove(match); | 71 | matches.remove(match); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | public int size() { | 74 | public int size() { |
| 75 | return m_matches.size(); | 75 | return matches.size(); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | @Override | 78 | @Override |
| 79 | public Iterator<ClassMatch> iterator() { | 79 | public Iterator<ClassMatch> iterator() { |
| 80 | return m_matches.iterator(); | 80 | return matches.iterator(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | private void indexMatch(ClassMatch match) { | 83 | private void indexMatch(ClassMatch match) { |
| 84 | if (!match.isMatched()) { | 84 | if (!match.isMatched()) { |
| 85 | // unmatched | 85 | // unmatched |
| 86 | m_unmatchedSourceClasses.addAll(match.sourceClasses); | 86 | unmatchedSourceClasses.addAll(match.sourceClasses); |
| 87 | m_unmatchedDestClasses.addAll(match.destClasses); | 87 | unmatchedDestClasses.addAll(match.destClasses); |
| 88 | } else { | 88 | } else { |
| 89 | if (match.isAmbiguous()) { | 89 | if (match.isAmbiguous()) { |
| 90 | // ambiguously matched | 90 | // ambiguously matched |
| 91 | for (ClassEntry entry : match.sourceClasses) { | 91 | for (ClassEntry entry : match.sourceClasses) { |
| 92 | m_ambiguousMatchesBySource.put(entry, match); | 92 | ambiguousMatchesBySource.put(entry, match); |
| 93 | } | 93 | } |
| 94 | for (ClassEntry entry : match.destClasses) { | 94 | for (ClassEntry entry : match.destClasses) { |
| 95 | m_ambiguousMatchesByDest.put(entry, match); | 95 | ambiguousMatchesByDest.put(entry, match); |
| 96 | } | 96 | } |
| 97 | } else { | 97 | } else { |
| 98 | // uniquely matched | 98 | // uniquely matched |
| 99 | m_uniqueMatches.put(match.getUniqueSource(), match.getUniqueDest()); | 99 | uniqueMatches.put(match.getUniqueSource(), match.getUniqueDest()); |
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | for (ClassEntry entry : match.sourceClasses) { | 102 | for (ClassEntry entry : match.sourceClasses) { |
| 103 | m_matchesBySource.put(entry, match); | 103 | matchesBySource.put(entry, match); |
| 104 | } | 104 | } |
| 105 | for (ClassEntry entry : match.destClasses) { | 105 | for (ClassEntry entry : match.destClasses) { |
| 106 | m_matchesByDest.put(entry, match); | 106 | matchesByDest.put(entry, match); |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | public BiMap<ClassEntry, ClassEntry> getUniqueMatches() { | 110 | public BiMap<ClassEntry, ClassEntry> getUniqueMatches() { |
| 111 | return m_uniqueMatches; | 111 | return uniqueMatches; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | public Set<ClassEntry> getUnmatchedSourceClasses() { | 114 | public Set<ClassEntry> getUnmatchedSourceClasses() { |
| 115 | return m_unmatchedSourceClasses; | 115 | return unmatchedSourceClasses; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | public Set<ClassEntry> getUnmatchedDestClasses() { | 118 | public Set<ClassEntry> getUnmatchedDestClasses() { |
| 119 | return m_unmatchedDestClasses; | 119 | return unmatchedDestClasses; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | public Set<ClassEntry> getAmbiguouslyMatchedSourceClasses() { | 122 | public Set<ClassEntry> getAmbiguouslyMatchedSourceClasses() { |
| 123 | return m_ambiguousMatchesBySource.keySet(); | 123 | return ambiguousMatchesBySource.keySet(); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | public ClassMatch getAmbiguousMatchBySource(ClassEntry sourceClass) { | 126 | public ClassMatch getAmbiguousMatchBySource(ClassEntry sourceClass) { |
| 127 | return m_ambiguousMatchesBySource.get(sourceClass); | 127 | return ambiguousMatchesBySource.get(sourceClass); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | public ClassMatch getMatchBySource(ClassEntry sourceClass) { | 130 | public ClassMatch getMatchBySource(ClassEntry sourceClass) { |
| 131 | return m_matchesBySource.get(sourceClass); | 131 | return matchesBySource.get(sourceClass); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | public ClassMatch getMatchByDest(ClassEntry destClass) { | 134 | public ClassMatch getMatchByDest(ClassEntry destClass) { |
| 135 | return m_matchesByDest.get(destClass); | 135 | return matchesByDest.get(destClass); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | public void removeSource(ClassEntry sourceClass) { | 138 | public void removeSource(ClassEntry sourceClass) { |
| 139 | ClassMatch match = m_matchesBySource.get(sourceClass); | 139 | ClassMatch match = matchesBySource.get(sourceClass); |
| 140 | if (match != null) { | 140 | if (match != null) { |
| 141 | remove(match); | 141 | remove(match); |
| 142 | match.sourceClasses.remove(sourceClass); | 142 | match.sourceClasses.remove(sourceClass); |
| @@ -147,7 +147,7 @@ public class ClassMatches implements Iterable<ClassMatch> { | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | public void removeDest(ClassEntry destClass) { | 149 | public void removeDest(ClassEntry destClass) { |
| 150 | ClassMatch match = m_matchesByDest.get(destClass); | 150 | ClassMatch match = matchesByDest.get(destClass); |
| 151 | if (match != null) { | 151 | if (match != null) { |
| 152 | remove(match); | 152 | remove(match); |
| 153 | match.destClasses.remove(destClass); | 153 | match.destClasses.remove(destClass); |