diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java index 626af57..6cc9eb7 100644 --- a/src/cuchaz/enigma/mapping/FieldEntry.java +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -14,90 +14,75 @@ import java.io.Serializable; | |||
| 14 | 14 | ||
| 15 | import cuchaz.enigma.Util; | 15 | import cuchaz.enigma.Util; |
| 16 | 16 | ||
| 17 | public class FieldEntry implements Entry, Serializable | 17 | public class FieldEntry implements Entry, Serializable { |
| 18 | { | 18 | |
| 19 | private static final long serialVersionUID = 3004663582802885451L; | 19 | private static final long serialVersionUID = 3004663582802885451L; |
| 20 | 20 | ||
| 21 | private ClassEntry m_classEntry; | 21 | private ClassEntry m_classEntry; |
| 22 | private String m_name; | 22 | private String m_name; |
| 23 | 23 | ||
| 24 | // NOTE: this argument order is important for the MethodReader/MethodWriter | 24 | // NOTE: this argument order is important for the MethodReader/MethodWriter |
| 25 | public FieldEntry( ClassEntry classEntry, String name ) | 25 | public FieldEntry(ClassEntry classEntry, String name) { |
| 26 | { | 26 | if (classEntry == null) { |
| 27 | if( classEntry == null ) | 27 | throw new IllegalArgumentException("Class cannot be null!"); |
| 28 | { | ||
| 29 | throw new IllegalArgumentException( "Class cannot be null!" ); | ||
| 30 | } | 28 | } |
| 31 | if( name == null ) | 29 | if (name == null) { |
| 32 | { | 30 | throw new IllegalArgumentException("Field name cannot be null!"); |
| 33 | throw new IllegalArgumentException( "Field name cannot be null!" ); | ||
| 34 | } | 31 | } |
| 35 | 32 | ||
| 36 | m_classEntry = classEntry; | 33 | m_classEntry = classEntry; |
| 37 | m_name = name; | 34 | m_name = name; |
| 38 | } | 35 | } |
| 39 | 36 | ||
| 40 | public FieldEntry( FieldEntry other ) | 37 | public FieldEntry(FieldEntry other) { |
| 41 | { | 38 | m_classEntry = new ClassEntry(other.m_classEntry); |
| 42 | m_classEntry = new ClassEntry( other.m_classEntry ); | ||
| 43 | m_name = other.m_name; | 39 | m_name = other.m_name; |
| 44 | } | 40 | } |
| 45 | 41 | ||
| 46 | public FieldEntry( FieldEntry other, String newClassName ) | 42 | public FieldEntry(FieldEntry other, String newClassName) { |
| 47 | { | 43 | m_classEntry = new ClassEntry(newClassName); |
| 48 | m_classEntry = new ClassEntry( newClassName ); | ||
| 49 | m_name = other.m_name; | 44 | m_name = other.m_name; |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | @Override | 47 | @Override |
| 53 | public ClassEntry getClassEntry( ) | 48 | public ClassEntry getClassEntry() { |
| 54 | { | ||
| 55 | return m_classEntry; | 49 | return m_classEntry; |
| 56 | } | 50 | } |
| 57 | 51 | ||
| 58 | @Override | 52 | @Override |
| 59 | public String getName( ) | 53 | public String getName() { |
| 60 | { | ||
| 61 | return m_name; | 54 | return m_name; |
| 62 | } | 55 | } |
| 63 | 56 | ||
| 64 | @Override | 57 | @Override |
| 65 | public String getClassName( ) | 58 | public String getClassName() { |
| 66 | { | ||
| 67 | return m_classEntry.getName(); | 59 | return m_classEntry.getName(); |
| 68 | } | 60 | } |
| 69 | 61 | ||
| 70 | @Override | 62 | @Override |
| 71 | public FieldEntry cloneToNewClass( ClassEntry classEntry ) | 63 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { |
| 72 | { | 64 | return new FieldEntry(this, classEntry.getName()); |
| 73 | return new FieldEntry( this, classEntry.getName() ); | ||
| 74 | } | 65 | } |
| 75 | 66 | ||
| 76 | @Override | 67 | @Override |
| 77 | public int hashCode( ) | 68 | public int hashCode() { |
| 78 | { | 69 | return Util.combineHashesOrdered(m_classEntry, m_name); |
| 79 | return Util.combineHashesOrdered( m_classEntry, m_name ); | ||
| 80 | } | 70 | } |
| 81 | 71 | ||
| 82 | @Override | 72 | @Override |
| 83 | public boolean equals( Object other ) | 73 | public boolean equals(Object other) { |
| 84 | { | 74 | if (other instanceof FieldEntry) { |
| 85 | if( other instanceof FieldEntry ) | 75 | return equals((FieldEntry)other); |
| 86 | { | ||
| 87 | return equals( (FieldEntry)other ); | ||
| 88 | } | 76 | } |
| 89 | return false; | 77 | return false; |
| 90 | } | 78 | } |
| 91 | 79 | ||
| 92 | public boolean equals( FieldEntry other ) | 80 | public boolean equals(FieldEntry other) { |
| 93 | { | 81 | return m_classEntry.equals(other.m_classEntry) && m_name.equals(other.m_name); |
| 94 | return m_classEntry.equals( other.m_classEntry ) | ||
| 95 | && m_name.equals( other.m_name ); | ||
| 96 | } | 82 | } |
| 97 | 83 | ||
| 98 | @Override | 84 | @Override |
| 99 | public String toString( ) | 85 | public String toString() { |
| 100 | { | ||
| 101 | return m_classEntry.getName() + "." + m_name; | 86 | return m_classEntry.getName() + "." + m_name; |
| 102 | } | 87 | } |
| 103 | } | 88 | } |