blob: b6e1554ded33c86c34dcca448b99c042a88b13fd (
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
|
/*******************************************************************************
* Copyright (c) 2015 Jeff Martin.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public
* License v3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Contributors:
* Jeff Martin - initial API and implementation
******************************************************************************/
package cuchaz.enigma.mapping.entry;
import com.google.common.base.Preconditions;
import cuchaz.enigma.mapping.TypeDescriptor;
import cuchaz.enigma.utils.Utils;
public class FieldEntry implements Entry {
protected final ClassEntry ownerEntry;
protected final String name;
protected final TypeDescriptor desc;
// NOTE: this argument order is important for the MethodReader/MethodWriter
public FieldEntry(ClassEntry ownerEntry, String name, TypeDescriptor desc) {
Preconditions.checkNotNull(ownerEntry, "Owner cannot be null");
Preconditions.checkNotNull(name, "Field name cannot be null");
Preconditions.checkNotNull(desc, "Field descriptor cannot be null");
this.ownerEntry = ownerEntry;
this.name = name;
this.desc = desc;
}
@Override
public ClassEntry getOwnerClassEntry() {
return this.ownerEntry;
}
@Override
public String getName() {
return this.name;
}
@Override
public String getClassName() {
return this.ownerEntry.getName();
}
public TypeDescriptor getDesc() {
return this.desc;
}
@Override
public FieldEntry updateOwnership(ClassEntry owner) {
return new FieldEntry(owner, this.name, this.desc);
}
@Override
public int hashCode() {
return Utils.combineHashesOrdered(this.ownerEntry, this.name, this.desc);
}
@Override
public boolean equals(Object other) {
return other instanceof FieldEntry && equals((FieldEntry) other);
}
public boolean equals(FieldEntry other) {
return this.ownerEntry.equals(other.ownerEntry) && this.name.equals(other.name) && this.desc.equals(other.desc);
}
@Override
public String toString() {
return this.ownerEntry.getName() + "." + this.name + ":" + this.desc;
}
}
|