summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/MethodMapping.java
diff options
context:
space:
mode:
authorGravatar asiekierka2016-08-17 18:35:12 +0200
committerGravatar asiekierka2016-08-17 18:35:12 +0200
commit5540c815de36e316d0749ce2163f12c61895b327 (patch)
tree2b30d5ae98735ee7cba7d1c0087c51d68ed3ebf9 /src/main/java/cuchaz/enigma/mapping/MethodMapping.java
parentRevert "Removed util" (diff)
downloadenigma-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/MethodMapping.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/MethodMapping.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/MethodMapping.java b/src/main/java/cuchaz/enigma/mapping/MethodMapping.java
index 6e7c1ef..99b9c88 100644
--- a/src/main/java/cuchaz/enigma/mapping/MethodMapping.java
+++ b/src/main/java/cuchaz/enigma/mapping/MethodMapping.java
@@ -39,6 +39,16 @@ public class MethodMapping implements Comparable<MethodMapping>, MemberMapping<B
39 this.obfSignature = obfSignature; 39 this.obfSignature = obfSignature;
40 this.arguments = Maps.newTreeMap(); 40 this.arguments = Maps.newTreeMap();
41 } 41 }
42
43 public MethodMapping(MethodMapping other, ClassNameReplacer obfClassNameReplacer) {
44 this.obfName = other.obfName;
45 this.deobfName = other.deobfName;
46 this.obfSignature = new Signature(other.obfSignature, obfClassNameReplacer);
47 this.arguments = Maps.newTreeMap();
48 for (Map.Entry<Integer,ArgumentMapping> entry : other.arguments.entrySet()) {
49 this.arguments.put(entry.getKey(), new ArgumentMapping(entry.getValue()));
50 }
51 }
42 52
43 @Override 53 @Override
44 public String getObfName() { 54 public String getObfName() {
@@ -57,6 +67,14 @@ public class MethodMapping implements Comparable<MethodMapping>, MemberMapping<B
57 return this.obfSignature; 67 return this.obfSignature;
58 } 68 }
59 69
70 public void setObfName(String name) {
71 this.obfName = NameValidator.validateMethodName(name);
72 }
73
74 public void setObfSignature(Signature val) {
75 this.obfSignature = val;
76 }
77
60 public Iterable<ArgumentMapping> arguments() { 78 public Iterable<ArgumentMapping> arguments() {
61 return this.arguments.values(); 79 return this.arguments.values();
62 } 80 }
@@ -137,4 +155,36 @@ public class MethodMapping implements Comparable<MethodMapping>, MemberMapping<B
137 } 155 }
138 return false; 156 return false;
139 } 157 }
158
159 public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) {
160 // rename obf classes in the signature
161 Signature newSignature = new Signature(this.obfSignature, new ClassNameReplacer() {
162 @Override
163 public String replace(String className) {
164 if (className.equals(oldObfClassName)) {
165 return newObfClassName;
166 }
167 return null;
168 }
169 });
170
171 if (!newSignature.equals(this.obfSignature)) {
172 this.obfSignature = newSignature;
173 return true;
174 }
175 return false;
176 }
177
178 public boolean isConstructor() {
179 return this.obfName.startsWith("<");
180 }
181
182 @Override
183 public BehaviorEntry getObfEntry(ClassEntry classEntry) {
184 if (isConstructor()) {
185 return new ConstructorEntry(classEntry, this.obfSignature);
186 } else {
187 return new MethodEntry(classEntry, this.obfName, this.obfSignature);
188 }
189 }
140} 190}