diff options
| author | 2015-02-08 21:29:25 -0500 | |
|---|---|---|
| committer | 2015-02-08 21:29:25 -0500 | |
| commit | ed9b5cdfc648e86fd463bfa8d86b94c41671e14c (patch) | |
| tree | 2619bbc7e04dfa3b82f8dfd3b1d31f529766cd4b /src/cuchaz/enigma/mapping/FieldEntry.java | |
| download | enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.gz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.xz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.zip | |
switch all classes to new signature/type system
Diffstat (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java new file mode 100644 index 0000000..6cc9eb7 --- /dev/null +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | import cuchaz.enigma.Util; | ||
| 16 | |||
| 17 | public class FieldEntry implements Entry, Serializable { | ||
| 18 | |||
| 19 | private static final long serialVersionUID = 3004663582802885451L; | ||
| 20 | |||
| 21 | private ClassEntry m_classEntry; | ||
| 22 | private String m_name; | ||
| 23 | |||
| 24 | // NOTE: this argument order is important for the MethodReader/MethodWriter | ||
| 25 | public FieldEntry(ClassEntry classEntry, String name) { | ||
| 26 | if (classEntry == null) { | ||
| 27 | throw new IllegalArgumentException("Class cannot be null!"); | ||
| 28 | } | ||
| 29 | if (name == null) { | ||
| 30 | throw new IllegalArgumentException("Field name cannot be null!"); | ||
| 31 | } | ||
| 32 | |||
| 33 | m_classEntry = classEntry; | ||
| 34 | m_name = name; | ||
| 35 | } | ||
| 36 | |||
| 37 | public FieldEntry(FieldEntry other) { | ||
| 38 | m_classEntry = new ClassEntry(other.m_classEntry); | ||
| 39 | m_name = other.m_name; | ||
| 40 | } | ||
| 41 | |||
| 42 | public FieldEntry(FieldEntry other, String newClassName) { | ||
| 43 | m_classEntry = new ClassEntry(newClassName); | ||
| 44 | m_name = other.m_name; | ||
| 45 | } | ||
| 46 | |||
| 47 | @Override | ||
| 48 | public ClassEntry getClassEntry() { | ||
| 49 | return m_classEntry; | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | public String getName() { | ||
| 54 | return m_name; | ||
| 55 | } | ||
| 56 | |||
| 57 | @Override | ||
| 58 | public String getClassName() { | ||
| 59 | return m_classEntry.getName(); | ||
| 60 | } | ||
| 61 | |||
| 62 | @Override | ||
| 63 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { | ||
| 64 | return new FieldEntry(this, classEntry.getName()); | ||
| 65 | } | ||
| 66 | |||
| 67 | @Override | ||
| 68 | public int hashCode() { | ||
| 69 | return Util.combineHashesOrdered(m_classEntry, m_name); | ||
| 70 | } | ||
| 71 | |||
| 72 | @Override | ||
| 73 | public boolean equals(Object other) { | ||
| 74 | if (other instanceof FieldEntry) { | ||
| 75 | return equals((FieldEntry)other); | ||
| 76 | } | ||
| 77 | return false; | ||
| 78 | } | ||
| 79 | |||
| 80 | public boolean equals(FieldEntry other) { | ||
| 81 | return m_classEntry.equals(other.m_classEntry) && m_name.equals(other.m_name); | ||
| 82 | } | ||
| 83 | |||
| 84 | @Override | ||
| 85 | public String toString() { | ||
| 86 | return m_classEntry.getName() + "." + m_name; | ||
| 87 | } | ||
| 88 | } | ||