summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/MethodEntry.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/MethodEntry.java145
1 files changed, 73 insertions, 72 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/MethodEntry.java b/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
index 4d7ed8f..9c3058c 100644
--- a/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
+++ b/src/main/java/cuchaz/enigma/mapping/MethodEntry.java
@@ -8,82 +8,83 @@
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.mapping; 12package cuchaz.enigma.mapping;
12 13
13import cuchaz.enigma.utils.Utils; 14import cuchaz.enigma.utils.Utils;
14 15
15public class MethodEntry implements BehaviorEntry { 16public class MethodEntry implements BehaviorEntry {
16 17
17 private ClassEntry classEntry; 18 private ClassEntry classEntry;
18 private String name; 19 private String name;
19 private Signature signature; 20 private Signature signature;
20 21
21 public MethodEntry(ClassEntry classEntry, String name, Signature signature) { 22 public MethodEntry(ClassEntry classEntry, String name, Signature signature) {
22 if (classEntry == null) { 23 if (classEntry == null) {
23 throw new IllegalArgumentException("Class cannot be null!"); 24 throw new IllegalArgumentException("Class cannot be null!");
24 } 25 }
25 if (name == null) { 26 if (name == null) {
26 throw new IllegalArgumentException("Method name cannot be null!"); 27 throw new IllegalArgumentException("Method name cannot be null!");
27 } 28 }
28 if (signature == null) { 29 if (signature == null) {
29 throw new IllegalArgumentException("Method signature cannot be null!"); 30 throw new IllegalArgumentException("Method signature cannot be null!");
30 } 31 }
31 if (name.startsWith("<")) { 32 if (name.startsWith("<")) {
32 throw new IllegalArgumentException("Don't use MethodEntry for a constructor!"); 33 throw new IllegalArgumentException("Don't use MethodEntry for a constructor!");
33 } 34 }
34 35
35 this.classEntry = classEntry; 36 this.classEntry = classEntry;
36 this.name = name; 37 this.name = name;
37 this.signature = signature; 38 this.signature = signature;
38 } 39 }
39 40
40 public MethodEntry(MethodEntry other, String newClassName) { 41 public MethodEntry(MethodEntry other, String newClassName) {
41 this.classEntry = new ClassEntry(newClassName); 42 this.classEntry = new ClassEntry(newClassName);
42 this.name = other.name; 43 this.name = other.name;
43 this.signature = other.signature; 44 this.signature = other.signature;
44 } 45 }
45 46
46 @Override 47 @Override
47 public ClassEntry getClassEntry() { 48 public ClassEntry getClassEntry() {
48 return this.classEntry; 49 return this.classEntry;
49 } 50 }
50 51
51 @Override 52 @Override
52 public String getName() { 53 public String getName() {
53 return this.name; 54 return this.name;
54 } 55 }
55 56
56 @Override 57 @Override
57 public Signature getSignature() { 58 public Signature getSignature() {
58 return this.signature; 59 return this.signature;
59 } 60 }
60 61
61 @Override 62 @Override
62 public String getClassName() { 63 public String getClassName() {
63 return this.classEntry.getName(); 64 return this.classEntry.getName();
64 } 65 }
65 66
66 @Override 67 @Override
67 public MethodEntry cloneToNewClass(ClassEntry classEntry) { 68 public MethodEntry cloneToNewClass(ClassEntry classEntry) {
68 return new MethodEntry(this, classEntry.getName()); 69 return new MethodEntry(this, classEntry.getName());
69 } 70 }
70 71
71 @Override 72 @Override
72 public int hashCode() { 73 public int hashCode() {
73 return Utils.combineHashesOrdered(this.classEntry, this.name, this.signature); 74 return Utils.combineHashesOrdered(this.classEntry, this.name, this.signature);
74 } 75 }
75 76
76 @Override 77 @Override
77 public boolean equals(Object other) { 78 public boolean equals(Object other) {
78 return other instanceof MethodEntry && equals((MethodEntry) other); 79 return other instanceof MethodEntry && equals((MethodEntry) other);
79 } 80 }
80 81
81 public boolean equals(MethodEntry other) { 82 public boolean equals(MethodEntry other) {
82 return this.classEntry.equals(other.classEntry) && this.name.equals(other.name) && this.signature.equals(other.signature); 83 return this.classEntry.equals(other.classEntry) && this.name.equals(other.name) && this.signature.equals(other.signature);
83 } 84 }
84 85
85 @Override 86 @Override
86 public String toString() { 87 public String toString() {
87 return this.classEntry.getName() + "." + this.name + this.signature; 88 return this.classEntry.getName() + "." + this.name + this.signature;
88 } 89 }
89} 90}