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
|
package cuchaz.enigma.translation.representation.entry;
import com.google.common.base.Preconditions;
import cuchaz.enigma.translation.Translator;
import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.TypeDescriptor;
import javax.annotation.Nullable;
/**
* TypeDescriptor...
* Created by Thog
* 19/10/2016
*/
public class LocalVariableDefEntry extends LocalVariableEntry {
protected final TypeDescriptor desc;
public LocalVariableDefEntry(MethodEntry ownerEntry, int index, String name, boolean parameter, TypeDescriptor desc, String javadoc) {
super(ownerEntry, index, name, parameter, javadoc);
Preconditions.checkNotNull(desc, "Variable desc cannot be null");
this.desc = desc;
}
public TypeDescriptor getDesc() {
return desc;
}
@Override
public LocalVariableDefEntry translate(Translator translator, @Nullable EntryMapping mapping) {
TypeDescriptor translatedDesc = translator.translate(desc);
String translatedName = mapping != null ? mapping.getTargetName() : name;
String javadoc = mapping != null ? mapping.getJavadoc() : javadocs;
return new LocalVariableDefEntry(parent, index, translatedName, parameter, translatedDesc, javadoc);
}
@Override
public LocalVariableDefEntry withName(String name) {
return new LocalVariableDefEntry(parent, index, name, parameter, desc, javadocs);
}
@Override
public LocalVariableDefEntry withParent(MethodEntry entry) {
return new LocalVariableDefEntry(entry, index, name, parameter, desc, javadocs);
}
@Override
public String toString() {
return this.parent + "(" + this.index + ":" + this.name + ":" + this.desc + ")";
}
}
|