blob: a794d0a0506e6453f6dec0b302d4f8e44c47b75a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package cuchaz.enigma.mapping.entry;
import com.google.common.base.Preconditions;
import cuchaz.enigma.mapping.MethodDescriptor;
import cuchaz.enigma.utils.Utils;
/**
* TypeDescriptor...
* Created by Thog
* 19/10/2016
*/
public class LocalVariableEntry implements Entry {
protected final MethodEntry ownerEntry;
protected final String name;
protected final int index;
public LocalVariableEntry(MethodEntry ownerEntry, int index, String name) {
Preconditions.checkNotNull(ownerEntry, "Variable owner cannot be null");
Preconditions.checkNotNull(name, "Variable name cannot be null");
Preconditions.checkArgument(index >= 0, "Index must be positive");
this.ownerEntry = ownerEntry;
this.name = name;
this.index = index;
}
public MethodEntry getOwnerEntry() {
return this.ownerEntry;
}
public int getIndex() {
return index;
}
@Override
public String getName() {
return this.name;
}
@Override
public ClassEntry getOwnerClassEntry() {
return this.ownerEntry.getOwnerClassEntry();
}
@Override
public String getClassName() {
return this.ownerEntry.getClassName();
}
@Override
public LocalVariableEntry updateOwnership(ClassEntry classEntry) {
return new LocalVariableEntry(ownerEntry.updateOwnership(classEntry), index, name);
}
public String getMethodName() {
return this.ownerEntry.getName();
}
public MethodDescriptor getMethodDesc() {
return this.ownerEntry.getDesc();
}
@Override
public int hashCode() {
return Utils.combineHashesOrdered(this.ownerEntry, this.name.hashCode(), Integer.hashCode(this.index));
}
@Override
public boolean equals(Object other) {
return other instanceof LocalVariableEntry && equals((LocalVariableEntry) other);
}
public boolean equals(LocalVariableEntry other) {
return this.ownerEntry.equals(other.ownerEntry) && this.name.equals(other.name) && this.index == other.index;
}
@Override
public String toString() {
return this.ownerEntry + "(" + this.index + ":" + this.name + ")";
}
}
|