summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java
diff options
context:
space:
mode:
authorGravatar Thog2017-03-08 08:17:04 +0100
committerGravatar Thog2017-03-08 08:17:04 +0100
commit6e464ea251cab63c776ece0b2a356f1498ffa294 (patch)
tree5ed30c03f5ac4cd2d6877874f5ede576049954f7 /src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java
parentDrop unix case style and implement hashCode when equals is overrided (diff)
downloadenigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.gz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.xz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.zip
Follow Fabric guidelines
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java185
1 files changed, 93 insertions, 92 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java b/src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java
index 662516d..9154cc2 100644
--- a/src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java
+++ b/src/main/java/cuchaz/enigma/mapping/ArgumentEntry.java
@@ -8,102 +8,103 @@
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 ArgumentEntry implements Entry { 16public class ArgumentEntry implements Entry {
16 17
17 private BehaviorEntry behaviorEntry; 18 private BehaviorEntry behaviorEntry;
18 private int index; 19 private int index;
19 private String name; 20 private String name;
20 21
21 public ArgumentEntry(BehaviorEntry behaviorEntry, int index, String name) { 22 public ArgumentEntry(BehaviorEntry behaviorEntry, int index, String name) {
22 if (behaviorEntry == null) { 23 if (behaviorEntry == null) {
23 throw new IllegalArgumentException("Behavior cannot be null!"); 24 throw new IllegalArgumentException("Behavior cannot be null!");
24 } 25 }
25 if (index < 0) { 26 if (index < 0) {
26 throw new IllegalArgumentException("Index must be non-negative!"); 27 throw new IllegalArgumentException("Index must be non-negative!");
27 } 28 }
28 if (name == null) { 29 if (name == null) {
29 throw new IllegalArgumentException("Argument name cannot be null!"); 30 throw new IllegalArgumentException("Argument name cannot be null!");
30 } 31 }
31 32
32 this.behaviorEntry = behaviorEntry; 33 this.behaviorEntry = behaviorEntry;
33 this.index = index; 34 this.index = index;
34 this.name = name; 35 this.name = name;
35 } 36 }
36 37
37 public ArgumentEntry(ArgumentEntry other) { 38 public ArgumentEntry(ArgumentEntry other) {
38 this.behaviorEntry = other.getBehaviorEntry(); 39 this.behaviorEntry = other.getBehaviorEntry();
39 this.index = other.index; 40 this.index = other.index;
40 this.name = other.name; 41 this.name = other.name;
41 } 42 }
42 43
43 public ArgumentEntry(ArgumentEntry other, String newClassName) { 44 public ArgumentEntry(ArgumentEntry other, String newClassName) {
44 this.behaviorEntry = (BehaviorEntry) other.behaviorEntry.cloneToNewClass(new ClassEntry(newClassName)); 45 this.behaviorEntry = (BehaviorEntry) other.behaviorEntry.cloneToNewClass(new ClassEntry(newClassName));
45 this.index = other.index; 46 this.index = other.index;
46 this.name = other.name; 47 this.name = other.name;
47 } 48 }
48 49
49 public ArgumentEntry(ArgumentEntry other, BehaviorEntry entry) { 50 public ArgumentEntry(ArgumentEntry other, BehaviorEntry entry) {
50 this.behaviorEntry = entry; 51 this.behaviorEntry = entry;
51 this.index = other.index; 52 this.index = other.index;
52 this.name = other.name; 53 this.name = other.name;
53 } 54 }
54 55
55 public BehaviorEntry getBehaviorEntry() { 56 public BehaviorEntry getBehaviorEntry() {
56 return this.behaviorEntry; 57 return this.behaviorEntry;
57 } 58 }
58 59
59 public int getIndex() { 60 public int getIndex() {
60 return this.index; 61 return this.index;
61 } 62 }
62 63
63 @Override 64 @Override
64 public String getName() { 65 public String getName() {
65 return this.name; 66 return this.name;
66 } 67 }
67 68
68 @Override 69 @Override
69 public ClassEntry getClassEntry() { 70 public ClassEntry getClassEntry() {
70 return this.behaviorEntry.getClassEntry(); 71 return this.behaviorEntry.getClassEntry();
71 } 72 }
72 73
73 @Override 74 @Override
74 public String getClassName() { 75 public String getClassName() {
75 return this.behaviorEntry.getClassName(); 76 return this.behaviorEntry.getClassName();
76 } 77 }
77 78
78 @Override 79 @Override
79 public ArgumentEntry cloneToNewClass(ClassEntry classEntry) { 80 public ArgumentEntry cloneToNewClass(ClassEntry classEntry) {
80 return new ArgumentEntry(this, classEntry.getName()); 81 return new ArgumentEntry(this, classEntry.getName());
81 } 82 }
82 83
83 public String getMethodName() { 84 public String getMethodName() {
84 return this.behaviorEntry.getName(); 85 return this.behaviorEntry.getName();
85 } 86 }
86 87
87 public Signature getMethodSignature() { 88 public Signature getMethodSignature() {
88 return this.behaviorEntry.getSignature(); 89 return this.behaviorEntry.getSignature();
89 } 90 }
90 91
91 @Override 92 @Override
92 public int hashCode() { 93 public int hashCode() {
93 return Utils.combineHashesOrdered(this.behaviorEntry, Integer.valueOf(this.index).hashCode(), this.name.hashCode()); 94 return Utils.combineHashesOrdered(this.behaviorEntry, Integer.valueOf(this.index).hashCode(), this.name.hashCode());
94 } 95 }
95 96
96 @Override 97 @Override
97 public boolean equals(Object other) { 98 public boolean equals(Object other) {
98 return other instanceof ArgumentEntry && equals((ArgumentEntry) other); 99 return other instanceof ArgumentEntry && equals((ArgumentEntry) other);
99 } 100 }
100 101
101 public boolean equals(ArgumentEntry other) { 102 public boolean equals(ArgumentEntry other) {
102 return this.behaviorEntry.equals(other.behaviorEntry) && this.index == other.index && this.name.equals(other.name); 103 return this.behaviorEntry.equals(other.behaviorEntry) && this.index == other.index && this.name.equals(other.name);
103 } 104 }
104 105
105 @Override 106 @Override
106 public String toString() { 107 public String toString() {
107 return this.behaviorEntry.toString() + "(" + this.index + ":" + this.name + ")"; 108 return this.behaviorEntry + "(" + this.index + ":" + this.name + ")";
108 } 109 }
109} 110}