blob: aa222652666572b663717a3957425cf26d56425d (
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
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2014 Jeff Martin.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Jeff Martin - initial API and implementation
******************************************************************************/
package cuchaz.enigma.mapping;
import java.io.Serializable;
import cuchaz.enigma.Util;
public class ArgumentEntry implements Entry, Serializable {
private static final long serialVersionUID = 4472172468162696006L;
private BehaviorEntry m_behaviorEntry;
private int m_index;
private String m_name;
public ArgumentEntry(BehaviorEntry behaviorEntry, int index, String name) {
if (behaviorEntry == null) {
throw new IllegalArgumentException("Behavior cannot be null!");
}
if (index < 0) {
throw new IllegalArgumentException("Index must be non-negative!");
}
if (name == null) {
throw new IllegalArgumentException("Argument name cannot be null!");
}
m_behaviorEntry = behaviorEntry;
m_index = index;
m_name = name;
}
public ArgumentEntry(ArgumentEntry other) {
m_behaviorEntry = (BehaviorEntry)m_behaviorEntry.cloneToNewClass(getClassEntry());
m_index = other.m_index;
m_name = other.m_name;
}
public ArgumentEntry(ArgumentEntry other, String newClassName) {
m_behaviorEntry = (BehaviorEntry)other.m_behaviorEntry.cloneToNewClass(new ClassEntry(newClassName));
m_index = other.m_index;
m_name = other.m_name;
}
public BehaviorEntry getBehaviorEntry() {
return m_behaviorEntry;
}
public int getIndex() {
return m_index;
}
@Override
public String getName() {
return m_name;
}
@Override
public ClassEntry getClassEntry() {
return m_behaviorEntry.getClassEntry();
}
@Override
public String getClassName() {
return m_behaviorEntry.getClassName();
}
@Override
public ArgumentEntry cloneToNewClass(ClassEntry classEntry) {
return new ArgumentEntry(this, classEntry.getName());
}
public String getMethodName() {
return m_behaviorEntry.getName();
}
public Signature getMethodSignature() {
return m_behaviorEntry.getSignature();
}
@Override
public int hashCode() {
return Util.combineHashesOrdered(
m_behaviorEntry,
Integer.valueOf(m_index).hashCode(),
m_name.hashCode()
);
}
@Override
public boolean equals(Object other) {
if (other instanceof ArgumentEntry) {
return equals((ArgumentEntry)other);
}
return false;
}
public boolean equals(ArgumentEntry other) {
return m_behaviorEntry.equals(other.m_behaviorEntry)
&& m_index == other.m_index
&& m_name.equals(other.m_name);
}
@Override
public String toString() {
return m_behaviorEntry.toString() + "(" + m_index + ":" + m_name + ")";
}
}
|