diff options
| author | 2015-05-21 23:30:00 +0100 | |
|---|---|---|
| committer | 2015-05-21 23:30:00 +0100 | |
| commit | e3f452250e51b7271f3989c7dfd12e4422934942 (patch) | |
| tree | 5aa482f9a6e21eb318a3e23e7d8274d77c73faf6 /src/cuchaz/enigma/mapping/FieldEntry.java | |
| download | enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.tar.gz enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.tar.xz enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.zip | |
Support Gradle alongside SSJB
This makes builds faster, simpler and better automated but still keeps
Cuchaz happy. :)
Diffstat (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 99 |
1 files changed, 99 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..e4a74f4 --- /dev/null +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.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 | private Type m_type; | ||
| 24 | |||
| 25 | // NOTE: this argument order is important for the MethodReader/MethodWriter | ||
| 26 | public FieldEntry(ClassEntry classEntry, String name, Type type) { | ||
| 27 | if (classEntry == null) { | ||
| 28 | throw new IllegalArgumentException("Class cannot be null!"); | ||
| 29 | } | ||
| 30 | if (name == null) { | ||
| 31 | throw new IllegalArgumentException("Field name cannot be null!"); | ||
| 32 | } | ||
| 33 | if (type == null) { | ||
| 34 | throw new IllegalArgumentException("Field type cannot be null!"); | ||
| 35 | } | ||
| 36 | |||
| 37 | m_classEntry = classEntry; | ||
| 38 | m_name = name; | ||
| 39 | m_type = type; | ||
| 40 | } | ||
| 41 | |||
| 42 | public FieldEntry(FieldEntry other) { | ||
| 43 | this(other, new ClassEntry(other.m_classEntry)); | ||
| 44 | } | ||
| 45 | |||
| 46 | public FieldEntry(FieldEntry other, ClassEntry newClassEntry) { | ||
| 47 | m_classEntry = newClassEntry; | ||
| 48 | m_name = other.m_name; | ||
| 49 | m_type = other.m_type; | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | public ClassEntry getClassEntry() { | ||
| 54 | return m_classEntry; | ||
| 55 | } | ||
| 56 | |||
| 57 | @Override | ||
| 58 | public String getName() { | ||
| 59 | return m_name; | ||
| 60 | } | ||
| 61 | |||
| 62 | @Override | ||
| 63 | public String getClassName() { | ||
| 64 | return m_classEntry.getName(); | ||
| 65 | } | ||
| 66 | |||
| 67 | public Type getType() { | ||
| 68 | return m_type; | ||
| 69 | } | ||
| 70 | |||
| 71 | @Override | ||
| 72 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { | ||
| 73 | return new FieldEntry(this, classEntry); | ||
| 74 | } | ||
| 75 | |||
| 76 | @Override | ||
| 77 | public int hashCode() { | ||
| 78 | return Util.combineHashesOrdered(m_classEntry, m_name, m_type); | ||
| 79 | } | ||
| 80 | |||
| 81 | @Override | ||
| 82 | public boolean equals(Object other) { | ||
| 83 | if (other instanceof FieldEntry) { | ||
| 84 | return equals((FieldEntry)other); | ||
| 85 | } | ||
| 86 | return false; | ||
| 87 | } | ||
| 88 | |||
| 89 | public boolean equals(FieldEntry other) { | ||
| 90 | return m_classEntry.equals(other.m_classEntry) | ||
| 91 | && m_name.equals(other.m_name) | ||
| 92 | && m_type.equals(other.m_type); | ||
| 93 | } | ||
| 94 | |||
| 95 | @Override | ||
| 96 | public String toString() { | ||
| 97 | return m_classEntry.getName() + "." + m_name + ":" + m_type; | ||
| 98 | } | ||
| 99 | } | ||