summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.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/LocalVariableEntry.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/LocalVariableEntry.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java186
1 files changed, 92 insertions, 94 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java b/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
index 8bbaaaf..2bb5e3f 100644
--- a/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
+++ b/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
@@ -7,98 +7,96 @@ import cuchaz.enigma.utils.Utils;
7 * Created by Thog 7 * Created by Thog
8 * 19/10/2016 8 * 19/10/2016
9 */ 9 */
10public class LocalVariableEntry implements Entry 10public class LocalVariableEntry implements Entry {
11{ 11
12 12 protected final BehaviorEntry behaviorEntry;
13 protected final BehaviorEntry behaviorEntry; 13 protected final String name;
14 protected final String name; 14 protected final Type type;
15 protected final Type type; 15 protected final int index;
16 protected final int index; 16
17 17 public LocalVariableEntry(BehaviorEntry behaviorEntry, int index, String name, Type type) {
18 public LocalVariableEntry(BehaviorEntry behaviorEntry, int index, String name, Type type) { 18 if (behaviorEntry == null) {
19 if (behaviorEntry == null) { 19 throw new IllegalArgumentException("Behavior cannot be null!");
20 throw new IllegalArgumentException("Behavior cannot be null!"); 20 }
21 } 21 if (index < 0) {
22 if (index < 0) { 22 throw new IllegalArgumentException("Index must be non-negative!");
23 throw new IllegalArgumentException("Index must be non-negative!"); 23 }
24 } 24 if (name == null) {
25 if (name == null) { 25 throw new IllegalArgumentException("Variable name cannot be null!");
26 throw new IllegalArgumentException("Variable name cannot be null!"); 26 }
27 } 27 if (type == null) {
28 if (type == null) { 28 throw new IllegalArgumentException("Variable type cannot be null!");
29 throw new IllegalArgumentException("Variable type cannot be null!"); 29 }
30 } 30
31 31 this.behaviorEntry = behaviorEntry;
32 this.behaviorEntry = behaviorEntry; 32 this.name = name;
33 this.name = name; 33 this.type = type;
34 this.type = type; 34 this.index = index;
35 this.index = index; 35 }
36 } 36
37 37 public LocalVariableEntry(LocalVariableEntry other, ClassEntry newClassEntry) {
38 38 this.behaviorEntry = (BehaviorEntry) other.behaviorEntry.cloneToNewClass(newClassEntry);
39 public LocalVariableEntry(LocalVariableEntry other, ClassEntry newClassEntry) { 39 this.name = other.name;
40 this.behaviorEntry = (BehaviorEntry) other.behaviorEntry.cloneToNewClass(newClassEntry); 40 this.type = other.type;
41 this.name = other.name; 41 this.index = other.index;
42 this.type = other.type; 42 }
43 this.index = other.index; 43
44 } 44 public BehaviorEntry getBehaviorEntry() {
45 45 return this.behaviorEntry;
46 public BehaviorEntry getBehaviorEntry() { 46 }
47 return this.behaviorEntry; 47
48 } 48 public Type getType() {
49 49 return type;
50 public Type getType() { 50 }
51 return type; 51
52 } 52 public int getIndex() {
53 53 return index;
54 public int getIndex() { 54 }
55 return index; 55
56 } 56 @Override
57 57 public String getName() {
58 @Override 58 return this.name;
59 public String getName() { 59 }
60 return this.name; 60
61 } 61 @Override
62 62 public ClassEntry getClassEntry() {
63 @Override 63 return this.behaviorEntry.getClassEntry();
64 public ClassEntry getClassEntry() { 64 }
65 return this.behaviorEntry.getClassEntry(); 65
66 } 66 @Override
67 67 public String getClassName() {
68 @Override 68 return this.behaviorEntry.getClassName();
69 public String getClassName() { 69 }
70 return this.behaviorEntry.getClassName(); 70
71 } 71 @Override
72 72 public LocalVariableEntry cloneToNewClass(ClassEntry classEntry) {
73 @Override 73 return new LocalVariableEntry(this, classEntry);
74 public LocalVariableEntry cloneToNewClass(ClassEntry classEntry) { 74 }
75 return new LocalVariableEntry(this, classEntry); 75
76 } 76 public String getMethodName() {
77 77 return this.behaviorEntry.getName();
78 public String getMethodName() { 78 }
79 return this.behaviorEntry.getName(); 79
80 } 80 public Signature getMethodSignature() {
81 81 return this.behaviorEntry.getSignature();
82 public Signature getMethodSignature() { 82 }
83 return this.behaviorEntry.getSignature(); 83
84 } 84 @Override
85 85 public int hashCode() {
86 @Override 86 return Utils.combineHashesOrdered(this.behaviorEntry, this.type.hashCode(), this.name.hashCode(), Integer.hashCode(this.index));
87 public int hashCode() { 87 }
88 return Utils.combineHashesOrdered(this.behaviorEntry, this.type.hashCode(), this.name.hashCode(), Integer.hashCode(this.index)); 88
89 } 89 @Override
90 90 public boolean equals(Object other) {
91 @Override 91 return other instanceof LocalVariableEntry && equals((LocalVariableEntry) other);
92 public boolean equals(Object other) { 92 }
93 return other instanceof LocalVariableEntry && equals((LocalVariableEntry) other); 93
94 } 94 public boolean equals(LocalVariableEntry other) {
95 95 return this.behaviorEntry.equals(other.behaviorEntry) && this.type.equals(other.type) && this.name.equals(other.name) && this.index == other.index;
96 public boolean equals(LocalVariableEntry other) { 96 }
97 return this.behaviorEntry.equals(other.behaviorEntry) && this.type.equals(other.type) && this.name.equals(other.name) && this.index == other.index; 97
98 } 98 @Override
99 99 public String toString() {
100 @Override 100 return this.behaviorEntry + "(" + this.index + ":" + this.name + ":" + this.type + ")";
101 public String toString() { 101 }
102 return this.behaviorEntry.toString() + "(" + this.index + ":" + this.name + ":" + this.type + ")";
103 }
104} 102}