summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
diff options
context:
space:
mode:
authorGravatar gegy10002018-05-19 17:02:46 +0200
committerGravatar gegy10002018-05-19 17:02:46 +0200
commit2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021 (patch)
tree14c8b1e806449ace1641a1dbafae162855f79670 /src/main/java/cuchaz/enigma/mapping/MethodEntry.java
parentFix build (diff)
downloadenigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.gz
enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.xz
enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.zip
Initial port to ASM
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/MethodEntry.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/MethodEntry.java59
1 files changed, 24 insertions, 35 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/MethodEntry.java b/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
index 9c3058c..f8a5ff1 100644
--- a/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
+++ b/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
@@ -11,41 +11,27 @@
11 11
12package cuchaz.enigma.mapping; 12package cuchaz.enigma.mapping;
13 13
14import com.google.common.base.Preconditions;
14import cuchaz.enigma.utils.Utils; 15import cuchaz.enigma.utils.Utils;
15 16
16public class MethodEntry implements BehaviorEntry { 17public class MethodEntry implements Entry {
17 18
18 private ClassEntry classEntry; 19 protected final ClassEntry classEntry;
19 private String name; 20 protected final String name;
20 private Signature signature; 21 protected final MethodDescriptor descriptor;
21 22
22 public MethodEntry(ClassEntry classEntry, String name, Signature signature) { 23 public MethodEntry(ClassEntry classEntry, String name, MethodDescriptor descriptor) {
23 if (classEntry == null) { 24 Preconditions.checkNotNull(classEntry, "Class cannot be null");
24 throw new IllegalArgumentException("Class cannot be null!"); 25 Preconditions.checkNotNull(name, "Method name cannot be null");
25 } 26 Preconditions.checkNotNull(descriptor, "Method descriptor cannot be null");
26 if (name == null) {
27 throw new IllegalArgumentException("Method name cannot be null!");
28 }
29 if (signature == null) {
30 throw new IllegalArgumentException("Method signature cannot be null!");
31 }
32 if (name.startsWith("<")) {
33 throw new IllegalArgumentException("Don't use MethodEntry for a constructor!");
34 }
35 27
36 this.classEntry = classEntry; 28 this.classEntry = classEntry;
37 this.name = name; 29 this.name = name;
38 this.signature = signature; 30 this.descriptor = descriptor;
39 }
40
41 public MethodEntry(MethodEntry other, String newClassName) {
42 this.classEntry = new ClassEntry(newClassName);
43 this.name = other.name;
44 this.signature = other.signature;
45 } 31 }
46 32
47 @Override 33 @Override
48 public ClassEntry getClassEntry() { 34 public ClassEntry getOwnerClassEntry() {
49 return this.classEntry; 35 return this.classEntry;
50 } 36 }
51 37
@@ -54,9 +40,12 @@ public class MethodEntry implements BehaviorEntry {
54 return this.name; 40 return this.name;
55 } 41 }
56 42
57 @Override 43 public MethodDescriptor getDesc() {
58 public Signature getSignature() { 44 return this.descriptor;
59 return this.signature; 45 }
46
47 public boolean isConstructor() {
48 return name.equals("<init>") || name.equals("<clinit>");
60 } 49 }
61 50
62 @Override 51 @Override
@@ -65,13 +54,13 @@ public class MethodEntry implements BehaviorEntry {
65 } 54 }
66 55
67 @Override 56 @Override
68 public MethodEntry cloneToNewClass(ClassEntry classEntry) { 57 public MethodEntry updateOwnership(ClassEntry classEntry) {
69 return new MethodEntry(this, classEntry.getName()); 58 return new MethodEntry(new ClassEntry(classEntry.getName()), name, descriptor);
70 } 59 }
71 60
72 @Override 61 @Override
73 public int hashCode() { 62 public int hashCode() {
74 return Utils.combineHashesOrdered(this.classEntry, this.name, this.signature); 63 return Utils.combineHashesOrdered(this.classEntry, this.name, this.descriptor);
75 } 64 }
76 65
77 @Override 66 @Override
@@ -80,11 +69,11 @@ public class MethodEntry implements BehaviorEntry {
80 } 69 }
81 70
82 public boolean equals(MethodEntry other) { 71 public boolean equals(MethodEntry other) {
83 return this.classEntry.equals(other.classEntry) && this.name.equals(other.name) && this.signature.equals(other.signature); 72 return this.classEntry.equals(other.getOwnerClassEntry()) && this.name.equals(other.getName()) && this.descriptor.equals(other.getDesc());
84 } 73 }
85 74
86 @Override 75 @Override
87 public String toString() { 76 public String toString() {
88 return this.classEntry.getName() + "." + this.name + this.signature; 77 return this.classEntry.getName() + "." + this.name + this.descriptor;
89 } 78 }
90} 79}