diff options
| author | 2015-02-08 23:10:26 -0500 | |
|---|---|---|
| committer | 2015-02-08 23:10:26 -0500 | |
| commit | 31a1a418b04cd3e7b06cb50cb8674a2c25079f6c (patch) | |
| tree | 5914fd0c3557250dc61382a571ea3a3cdb9d941d /src/cuchaz/enigma/mapping/FieldEntry.java | |
| parent | Merge with 09538fb039f2e4e5e240cfb331be512ae8740fda (diff) | |
| download | enigma-fork-31a1a418b04cd3e7b06cb50cb8674a2c25079f6c.tar.gz enigma-fork-31a1a418b04cd3e7b06cb50cb8674a2c25079f6c.tar.xz enigma-fork-31a1a418b04cd3e7b06cb50cb8674a2c25079f6c.zip | |
added types to fields
Diffstat (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java index 6cc9eb7..7517254 100644 --- a/src/cuchaz/enigma/mapping/FieldEntry.java +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -20,28 +20,33 @@ public class FieldEntry implements Entry, Serializable { | |||
| 20 | 20 | ||
| 21 | private ClassEntry m_classEntry; | 21 | private ClassEntry m_classEntry; |
| 22 | private String m_name; | 22 | private String m_name; |
| 23 | private Type m_type; | ||
| 23 | 24 | ||
| 24 | // NOTE: this argument order is important for the MethodReader/MethodWriter | 25 | // NOTE: this argument order is important for the MethodReader/MethodWriter |
| 25 | public FieldEntry(ClassEntry classEntry, String name) { | 26 | public FieldEntry(ClassEntry classEntry, String name, Type type) { |
| 26 | if (classEntry == null) { | 27 | if (classEntry == null) { |
| 27 | throw new IllegalArgumentException("Class cannot be null!"); | 28 | throw new IllegalArgumentException("Class cannot be null!"); |
| 28 | } | 29 | } |
| 29 | if (name == null) { | 30 | if (name == null) { |
| 30 | throw new IllegalArgumentException("Field name cannot be null!"); | 31 | throw new IllegalArgumentException("Field name cannot be null!"); |
| 31 | } | 32 | } |
| 33 | if (type == null) { | ||
| 34 | throw new IllegalArgumentException("Field type cannot be null!"); | ||
| 35 | } | ||
| 32 | 36 | ||
| 33 | m_classEntry = classEntry; | 37 | m_classEntry = classEntry; |
| 34 | m_name = name; | 38 | m_name = name; |
| 39 | m_type = type; | ||
| 35 | } | 40 | } |
| 36 | 41 | ||
| 37 | public FieldEntry(FieldEntry other) { | 42 | public FieldEntry(FieldEntry other) { |
| 38 | m_classEntry = new ClassEntry(other.m_classEntry); | 43 | this(other, new ClassEntry(other.m_classEntry)); |
| 39 | m_name = other.m_name; | ||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | public FieldEntry(FieldEntry other, String newClassName) { | 46 | public FieldEntry(FieldEntry other, ClassEntry newClassEntry) { |
| 43 | m_classEntry = new ClassEntry(newClassName); | 47 | m_classEntry = newClassEntry; |
| 44 | m_name = other.m_name; | 48 | m_name = other.m_name; |
| 49 | m_type = other.m_type; | ||
| 45 | } | 50 | } |
| 46 | 51 | ||
| 47 | @Override | 52 | @Override |
| @@ -59,14 +64,18 @@ public class FieldEntry implements Entry, Serializable { | |||
| 59 | return m_classEntry.getName(); | 64 | return m_classEntry.getName(); |
| 60 | } | 65 | } |
| 61 | 66 | ||
| 67 | public Type getType() { | ||
| 68 | return m_type; | ||
| 69 | } | ||
| 70 | |||
| 62 | @Override | 71 | @Override |
| 63 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { | 72 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { |
| 64 | return new FieldEntry(this, classEntry.getName()); | 73 | return new FieldEntry(this, classEntry); |
| 65 | } | 74 | } |
| 66 | 75 | ||
| 67 | @Override | 76 | @Override |
| 68 | public int hashCode() { | 77 | public int hashCode() { |
| 69 | return Util.combineHashesOrdered(m_classEntry, m_name); | 78 | return Util.combineHashesOrdered(m_classEntry, m_name, m_type); |
| 70 | } | 79 | } |
| 71 | 80 | ||
| 72 | @Override | 81 | @Override |
| @@ -78,11 +87,13 @@ public class FieldEntry implements Entry, Serializable { | |||
| 78 | } | 87 | } |
| 79 | 88 | ||
| 80 | public boolean equals(FieldEntry other) { | 89 | public boolean equals(FieldEntry other) { |
| 81 | return m_classEntry.equals(other.m_classEntry) && m_name.equals(other.m_name); | 90 | return m_classEntry.equals(other.m_classEntry) |
| 91 | && m_name.equals(other.m_name) | ||
| 92 | && m_type.equals(other.m_type); | ||
| 82 | } | 93 | } |
| 83 | 94 | ||
| 84 | @Override | 95 | @Override |
| 85 | public String toString() { | 96 | public String toString() { |
| 86 | return m_classEntry.getName() + "." + m_name; | 97 | return m_classEntry.getName() + "." + m_name + ":" + m_type; |
| 87 | } | 98 | } |
| 88 | } | 99 | } |