diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/FieldMapping.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/FieldMapping.java | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java index 19d68a9..3ec1af0 100644 --- a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java +++ b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java | |||
| @@ -10,11 +10,7 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.mapping; | 11 | package cuchaz.enigma.mapping; |
| 12 | 12 | ||
| 13 | import java.io.Serializable; | 13 | public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<FieldEntry> { |
| 14 | |||
| 15 | public class FieldMapping implements Serializable, Comparable<FieldMapping>, MemberMapping<FieldEntry> { | ||
| 16 | |||
| 17 | private static final long serialVersionUID = 8610742471440861315L; | ||
| 18 | 14 | ||
| 19 | private String obfName; | 15 | private String obfName; |
| 20 | private String deobfName; | 16 | private String deobfName; |
| @@ -26,21 +22,11 @@ public class FieldMapping implements Serializable, Comparable<FieldMapping>, Mem | |||
| 26 | this.obfType = obfType; | 22 | this.obfType = obfType; |
| 27 | } | 23 | } |
| 28 | 24 | ||
| 29 | public FieldMapping(FieldMapping other, ClassNameReplacer obfClassNameReplacer) { | ||
| 30 | this.obfName = other.obfName; | ||
| 31 | this.deobfName = other.deobfName; | ||
| 32 | this.obfType = new Type(other.obfType, obfClassNameReplacer); | ||
| 33 | } | ||
| 34 | |||
| 35 | @Override | 25 | @Override |
| 36 | public String getObfName() { | 26 | public String getObfName() { |
| 37 | return this.obfName; | 27 | return this.obfName; |
| 38 | } | 28 | } |
| 39 | 29 | ||
| 40 | public void setObfName(String val) { | ||
| 41 | this.obfName = NameValidator.validateFieldName(val); | ||
| 42 | } | ||
| 43 | |||
| 44 | public String getDeobfName() { | 30 | public String getDeobfName() { |
| 45 | return this.deobfName; | 31 | return this.deobfName; |
| 46 | } | 32 | } |
| @@ -53,34 +39,8 @@ public class FieldMapping implements Serializable, Comparable<FieldMapping>, Mem | |||
| 53 | return this.obfType; | 39 | return this.obfType; |
| 54 | } | 40 | } |
| 55 | 41 | ||
| 56 | public void setObfType(Type val) { | ||
| 57 | this.obfType = val; | ||
| 58 | } | ||
| 59 | |||
| 60 | @Override | 42 | @Override |
| 61 | public int compareTo(FieldMapping other) { | 43 | public int compareTo(FieldMapping other) { |
| 62 | return (this.obfName + this.obfType).compareTo(other.obfName + other.obfType); | 44 | return (this.obfName + this.obfType).compareTo(other.obfName + other.obfType); |
| 63 | } | 45 | } |
| 64 | |||
| 65 | public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) { | ||
| 66 | |||
| 67 | // rename obf classes in the type | ||
| 68 | Type newType = new Type(this.obfType, className -> { | ||
| 69 | if (className.equals(oldObfClassName)) { | ||
| 70 | return newObfClassName; | ||
| 71 | } | ||
| 72 | return null; | ||
| 73 | }); | ||
| 74 | |||
| 75 | if (!newType.equals(this.obfType)) { | ||
| 76 | this.obfType = newType; | ||
| 77 | return true; | ||
| 78 | } | ||
| 79 | return false; | ||
| 80 | } | ||
| 81 | |||
| 82 | @Override | ||
| 83 | public FieldEntry getObfEntry(ClassEntry classEntry) { | ||
| 84 | return new FieldEntry(classEntry, this.obfName, new Type(this.obfType)); | ||
| 85 | } | ||
| 86 | } | 46 | } |