blob: 626af57697702eb5e33090966b12a671c316ee5e (
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
|
/*******************************************************************************
* 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 FieldEntry implements Entry, Serializable
{
private static final long serialVersionUID = 3004663582802885451L;
private ClassEntry m_classEntry;
private String m_name;
// NOTE: this argument order is important for the MethodReader/MethodWriter
public FieldEntry( ClassEntry classEntry, String name )
{
if( classEntry == null )
{
throw new IllegalArgumentException( "Class cannot be null!" );
}
if( name == null )
{
throw new IllegalArgumentException( "Field name cannot be null!" );
}
m_classEntry = classEntry;
m_name = name;
}
public FieldEntry( FieldEntry other )
{
m_classEntry = new ClassEntry( other.m_classEntry );
m_name = other.m_name;
}
public FieldEntry( FieldEntry other, String newClassName )
{
m_classEntry = new ClassEntry( newClassName );
m_name = other.m_name;
}
@Override
public ClassEntry getClassEntry( )
{
return m_classEntry;
}
@Override
public String getName( )
{
return m_name;
}
@Override
public String getClassName( )
{
return m_classEntry.getName();
}
@Override
public FieldEntry cloneToNewClass( ClassEntry classEntry )
{
return new FieldEntry( this, classEntry.getName() );
}
@Override
public int hashCode( )
{
return Util.combineHashesOrdered( m_classEntry, m_name );
}
@Override
public boolean equals( Object other )
{
if( other instanceof FieldEntry )
{
return equals( (FieldEntry)other );
}
return false;
}
public boolean equals( FieldEntry other )
{
return m_classEntry.equals( other.m_classEntry )
&& m_name.equals( other.m_name );
}
@Override
public String toString( )
{
return m_classEntry.getName() + "." + m_name;
}
}
|