From 31a1a418b04cd3e7b06cb50cb8674a2c25079f6c Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 8 Feb 2015 23:10:26 -0500 Subject: added types to fields --- src/cuchaz/enigma/mapping/FieldEntry.java | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java') 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 { private ClassEntry m_classEntry; private String m_name; + private Type m_type; // NOTE: this argument order is important for the MethodReader/MethodWriter - public FieldEntry(ClassEntry classEntry, String name) { + public FieldEntry(ClassEntry classEntry, String name, Type type) { if (classEntry == null) { throw new IllegalArgumentException("Class cannot be null!"); } if (name == null) { throw new IllegalArgumentException("Field name cannot be null!"); } + if (type == null) { + throw new IllegalArgumentException("Field type cannot be null!"); + } m_classEntry = classEntry; m_name = name; + m_type = type; } public FieldEntry(FieldEntry other) { - m_classEntry = new ClassEntry(other.m_classEntry); - m_name = other.m_name; + this(other, new ClassEntry(other.m_classEntry)); } - public FieldEntry(FieldEntry other, String newClassName) { - m_classEntry = new ClassEntry(newClassName); + public FieldEntry(FieldEntry other, ClassEntry newClassEntry) { + m_classEntry = newClassEntry; m_name = other.m_name; + m_type = other.m_type; } @Override @@ -59,14 +64,18 @@ public class FieldEntry implements Entry, Serializable { return m_classEntry.getName(); } + public Type getType() { + return m_type; + } + @Override public FieldEntry cloneToNewClass(ClassEntry classEntry) { - return new FieldEntry(this, classEntry.getName()); + return new FieldEntry(this, classEntry); } @Override public int hashCode() { - return Util.combineHashesOrdered(m_classEntry, m_name); + return Util.combineHashesOrdered(m_classEntry, m_name, m_type); } @Override @@ -78,11 +87,13 @@ public class FieldEntry implements Entry, Serializable { } public boolean equals(FieldEntry other) { - return m_classEntry.equals(other.m_classEntry) && m_name.equals(other.m_name); + return m_classEntry.equals(other.m_classEntry) + && m_name.equals(other.m_name) + && m_type.equals(other.m_type); } @Override public String toString() { - return m_classEntry.getName() + "." + m_name; + return m_classEntry.getName() + "." + m_name + ":" + m_type; } } -- cgit v1.2.3