blob: 20e51138fb70f470890af47949674067bf3092dc (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*******************************************************************************
* 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;
import cuchaz.enigma.utils.Utils;
public class ConstructorEntry implements BehaviorEntry {
private ClassEntry classEntry;
private Signature signature;
public ConstructorEntry(ClassEntry classEntry) {
this(classEntry, null);
}
public ConstructorEntry(ClassEntry classEntry, Signature signature) {
if (classEntry == null) {
throw new IllegalArgumentException("Class cannot be null!");
}
this.classEntry = classEntry;
this.signature = signature;
}
public ConstructorEntry(ConstructorEntry other, String newClassName) {
this.classEntry = new ClassEntry(newClassName);
this.signature = other.signature;
}
@Override
public ClassEntry getClassEntry() {
return this.classEntry;
}
@Override
public String getName() {
if (isStatic()) {
return "<clinit>";
}
return "<init>";
}
public boolean isStatic() {
return this.signature == null;
}
@Override
public Signature getSignature() {
return this.signature;
}
@Override
public String getClassName() {
return this.classEntry.getName();
}
@Override
public ConstructorEntry cloneToNewClass(ClassEntry classEntry) {
return new ConstructorEntry(this, classEntry.getName());
}
@Override
public int hashCode() {
if (isStatic()) {
return Utils.combineHashesOrdered(this.classEntry);
} else {
return Utils.combineHashesOrdered(this.classEntry, this.signature);
}
}
@Override
public boolean equals(Object other) {
return other instanceof ConstructorEntry && equals((ConstructorEntry) other);
}
public boolean equals(ConstructorEntry other) {
if (isStatic() != other.isStatic()) {
return false;
}
if (isStatic()) {
return this.classEntry.equals(other.classEntry);
} else {
return this.classEntry.equals(other.classEntry) && this.signature.equals(other.signature);
}
}
@Override
public String toString() {
if (isStatic()) {
return this.classEntry.getName() + "." + getName();
} else {
return this.classEntry.getName() + "." + getName() + this.signature;
}
}
}
|