diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/ClassMapping.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/ClassMapping.java | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/ClassMapping.java b/src/main/java/cuchaz/enigma/mapping/ClassMapping.java index f831a3b..b2c076a 100644 --- a/src/main/java/cuchaz/enigma/mapping/ClassMapping.java +++ b/src/main/java/cuchaz/enigma/mapping/ClassMapping.java | |||
| @@ -12,13 +12,11 @@ package cuchaz.enigma.mapping; | |||
| 12 | 12 | ||
| 13 | import com.google.common.collect.Maps; | 13 | import com.google.common.collect.Maps; |
| 14 | 14 | ||
| 15 | import java.io.Serializable; | ||
| 16 | import java.util.ArrayList; | ||
| 17 | import java.util.Map; | 15 | import java.util.Map; |
| 18 | 16 | ||
| 19 | public class ClassMapping implements Serializable, Comparable<ClassMapping> { | 17 | import cuchaz.enigma.throwables.MappingConflict; |
| 20 | 18 | ||
| 21 | private static final long serialVersionUID = -5148491146902340107L; | 19 | public class ClassMapping implements Comparable<ClassMapping> { |
| 22 | 20 | ||
| 23 | private String m_obfFullName; | 21 | private String m_obfFullName; |
| 24 | private String m_obfSimpleName; | 22 | private String m_obfSimpleName; |
| @@ -70,13 +68,17 @@ public class ClassMapping implements Serializable, Comparable<ClassMapping> { | |||
| 70 | return m_innerClassesByObfSimple.values(); | 68 | return m_innerClassesByObfSimple.values(); |
| 71 | } | 69 | } |
| 72 | 70 | ||
| 73 | public void addInnerClassMapping(ClassMapping classMapping) { | 71 | public void addInnerClassMapping(ClassMapping classMapping) throws MappingConflict { |
| 74 | boolean obfWasAdded = m_innerClassesByObfSimple.put(classMapping.getObfSimpleName(), classMapping) == null; | 72 | if (this.m_innerClassesByObfSimple.containsKey(classMapping.getObfSimpleName())) { |
| 75 | assert (obfWasAdded); | 73 | throw new MappingConflict("classes", classMapping.getObfSimpleName(), this.m_innerClassesByObfSimple.get(classMapping.getObfSimpleName()).getObfSimpleName()); |
| 74 | } | ||
| 75 | m_innerClassesByObfSimple.put(classMapping.getObfSimpleName(), classMapping); | ||
| 76 | |||
| 76 | if (classMapping.getDeobfName() != null) { | 77 | if (classMapping.getDeobfName() != null) { |
| 77 | assert (isSimpleClassName(classMapping.getDeobfName())); | 78 | if (this.m_innerClassesByDeobf.containsKey(classMapping.getDeobfName())) { |
| 78 | boolean deobfWasAdded = m_innerClassesByDeobf.put(classMapping.getDeobfName(), classMapping) == null; | 79 | throw new MappingConflict("classes", classMapping.getDeobfName(), this.m_innerClassesByDeobf.get(classMapping.getDeobfName()).getDeobfName()); |
| 79 | assert (deobfWasAdded); | 80 | } |
| 81 | m_innerClassesByDeobf.put(classMapping.getDeobfName(), classMapping); | ||
| 80 | } | 82 | } |
| 81 | } | 83 | } |
| 82 | 84 | ||
| @@ -225,17 +227,6 @@ public class ClassMapping implements Serializable, Comparable<ClassMapping> { | |||
| 225 | } | 227 | } |
| 226 | } | 228 | } |
| 227 | 229 | ||
| 228 | public void setFieldObfNameAndType(String oldObfName, Type obfType, String newObfName, Type newObfType) { | ||
| 229 | assert (newObfName != null); | ||
| 230 | FieldMapping fieldMapping = m_fieldsByObf.remove(getFieldKey(oldObfName, obfType)); | ||
| 231 | assert (fieldMapping != null); | ||
| 232 | fieldMapping.setObfName(newObfName); | ||
| 233 | fieldMapping.setObfType(newObfType); | ||
| 234 | boolean obfWasAdded = m_fieldsByObf.put(getFieldKey(newObfName, newObfType), fieldMapping) == null; | ||
| 235 | assert (obfWasAdded); | ||
| 236 | } | ||
| 237 | |||
| 238 | |||
| 239 | //// METHODS //////// | 230 | //// METHODS //////// |
| 240 | 231 | ||
| 241 | public Iterable<MethodMapping> methods() { | 232 | public Iterable<MethodMapping> methods() { |
| @@ -307,16 +298,6 @@ public class ClassMapping implements Serializable, Comparable<ClassMapping> { | |||
| 307 | } | 298 | } |
| 308 | } | 299 | } |
| 309 | 300 | ||
| 310 | public void setMethodObfNameAndSignature(String oldObfName, Signature obfSignature, String newObfName, Signature newObfSignature) { | ||
| 311 | assert (newObfName != null); | ||
| 312 | MethodMapping methodMapping = m_methodsByObf.remove(getMethodKey(oldObfName, obfSignature)); | ||
| 313 | assert (methodMapping != null); | ||
| 314 | methodMapping.setObfName(newObfName); | ||
| 315 | methodMapping.setObfSignature(newObfSignature); | ||
| 316 | boolean obfWasAdded = m_methodsByObf.put(getMethodKey(newObfName, newObfSignature), methodMapping) == null; | ||
| 317 | assert (obfWasAdded); | ||
| 318 | } | ||
| 319 | |||
| 320 | //// ARGUMENTS //////// | 301 | //// ARGUMENTS //////// |
| 321 | 302 | ||
| 322 | public void setArgumentName(String obfMethodName, Signature obfMethodSignature, int argumentIndex, String argumentName) { | 303 | public void setArgumentName(String obfMethodName, Signature obfMethodSignature, int argumentIndex, String argumentName) { |
| @@ -388,7 +369,4 @@ public class ClassMapping implements Serializable, Comparable<ClassMapping> { | |||
| 388 | return name.indexOf('/') < 0 && name.indexOf('$') < 0; | 369 | return name.indexOf('/') < 0 && name.indexOf('$') < 0; |
| 389 | } | 370 | } |
| 390 | 371 | ||
| 391 | public ClassEntry getObfEntry() { | ||
| 392 | return new ClassEntry(m_obfFullName); | ||
| 393 | } | ||
| 394 | } | 372 | } |