diff options
| author | 2016-08-17 18:35:12 +0200 | |
|---|---|---|
| committer | 2016-08-17 18:35:12 +0200 | |
| commit | 5540c815de36e316d0749ce2163f12c61895b327 (patch) | |
| tree | 2b30d5ae98735ee7cba7d1c0087c51d68ed3ebf9 /src/main/java/cuchaz/enigma/mapping/FieldMapping.java | |
| parent | Revert "Removed util" (diff) | |
| download | enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.gz enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.xz enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.zip | |
Revert "Removed unused methods"
This reverts commit 1742190f784d0d62e7cc869eebafdfe1927e448f.
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/FieldMapping.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/FieldMapping.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java index 3ec1af0..1b59660 100644 --- a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java +++ b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java | |||
| @@ -22,6 +22,17 @@ public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<Fie | |||
| 22 | this.obfType = obfType; | 22 | this.obfType = obfType; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | public FieldMapping(FieldMapping other, ClassNameReplacer obfClassNameReplacer) { | ||
| 26 | this.obfName = other.obfName; | ||
| 27 | this.deobfName = other.deobfName; | ||
| 28 | this.obfType = new Type(other.obfType, obfClassNameReplacer); | ||
| 29 | } | ||
| 30 | |||
| 31 | @Override | ||
| 32 | public FieldEntry getObfEntry(ClassEntry classEntry) { | ||
| 33 | return new FieldEntry(classEntry, this.obfName, this.obfType); | ||
| 34 | } | ||
| 35 | |||
| 25 | @Override | 36 | @Override |
| 26 | public String getObfName() { | 37 | public String getObfName() { |
| 27 | return this.obfName; | 38 | return this.obfName; |
| @@ -35,12 +46,40 @@ public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<Fie | |||
| 35 | this.deobfName = NameValidator.validateFieldName(val); | 46 | this.deobfName = NameValidator.validateFieldName(val); |
| 36 | } | 47 | } |
| 37 | 48 | ||
| 49 | public void setObfName(String val) { | ||
| 50 | this.obfName = NameValidator.validateFieldName(val); | ||
| 51 | } | ||
| 52 | |||
| 38 | public Type getObfType() { | 53 | public Type getObfType() { |
| 39 | return this.obfType; | 54 | return this.obfType; |
| 40 | } | 55 | } |
| 41 | 56 | ||
| 57 | public void setObfType(Type val) { | ||
| 58 | this.obfType = val; | ||
| 59 | } | ||
| 60 | |||
| 42 | @Override | 61 | @Override |
| 43 | public int compareTo(FieldMapping other) { | 62 | public int compareTo(FieldMapping other) { |
| 44 | return (this.obfName + this.obfType).compareTo(other.obfName + other.obfType); | 63 | return (this.obfName + this.obfType).compareTo(other.obfName + other.obfType); |
| 45 | } | 64 | } |
| 65 | |||
| 66 | public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) { | ||
| 67 | // rename obf classes in the type | ||
| 68 | Type newType = new Type(this.obfType, new ClassNameReplacer() { | ||
| 69 | @Override | ||
| 70 | public String replace(String className) { | ||
| 71 | if (className.equals(oldObfClassName)) { | ||
| 72 | return newObfClassName; | ||
| 73 | } | ||
| 74 | return null; | ||
| 75 | } | ||
| 76 | }); | ||
| 77 | |||
| 78 | if (!newType.equals(this.obfType)) { | ||
| 79 | this.obfType = newType; | ||
| 80 | return true; | ||
| 81 | } | ||
| 82 | return false; | ||
| 83 | } | ||
| 84 | |||
| 46 | } | 85 | } |