-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
FieldDescription.java
38 lines (32 loc) · 1.01 KB
/
FieldDescription.java
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
package nallar.tickthreading.mappings;
public class FieldDescription {
public final String className;
public final String name;
private Integer cachedHashCode = null;
public FieldDescription(String className, String name) {
this.className = className;
this.name = name;
}
public FieldDescription(String MCPName) {
this(MCPName.substring(0, MCPName.lastIndexOf('/')).replace('/', '.'), MCPName.substring(MCPName.lastIndexOf('/') + 1));
}
@Override
public int hashCode() {
if (cachedHashCode != null) {
return cachedHashCode;
}
int hashCode = className.hashCode();
hashCode = 31 * hashCode + name.hashCode();
return (cachedHashCode = hashCode);
}
@Override
public boolean equals(Object other) {
return this == other || (other instanceof FieldDescription &&
((FieldDescription) other).className.equals(this.className) &&
((FieldDescription) other).name.equals(this.name));
}
@Override
public String toString() {
return className + '.' + name;
}
}