diff options
| author | 2017-03-08 08:17:04 +0100 | |
|---|---|---|
| committer | 2017-03-08 08:17:04 +0100 | |
| commit | 6e464ea251cab63c776ece0b2a356f1498ffa294 (patch) | |
| tree | 5ed30c03f5ac4cd2d6877874f5ede576049954f7 /src/main/java/cuchaz/enigma/mapping/FieldEntry.java | |
| parent | Drop unix case style and implement hashCode when equals is overrided (diff) | |
| download | enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.gz enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.xz enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.zip | |
Follow Fabric guidelines
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/FieldEntry.java | 139 |
1 files changed, 70 insertions, 69 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/FieldEntry.java b/src/main/java/cuchaz/enigma/mapping/FieldEntry.java index 9980e8e..0f1f506 100644 --- a/src/main/java/cuchaz/enigma/mapping/FieldEntry.java +++ b/src/main/java/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -8,79 +8,80 @@ | |||
| 8 | * Contributors: | 8 | * Contributors: |
| 9 | * Jeff Martin - initial API and implementation | 9 | * Jeff Martin - initial API and implementation |
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | |||
| 11 | package cuchaz.enigma.mapping; | 12 | package cuchaz.enigma.mapping; |
| 12 | 13 | ||
| 13 | import cuchaz.enigma.utils.Utils; | 14 | import cuchaz.enigma.utils.Utils; |
| 14 | 15 | ||
| 15 | public class FieldEntry implements Entry { | 16 | public class FieldEntry implements Entry { |
| 16 | 17 | ||
| 17 | private ClassEntry classEntry; | 18 | private ClassEntry classEntry; |
| 18 | private String name; | 19 | private String name; |
| 19 | private Type type; | 20 | private Type type; |
| 20 | 21 | ||
| 21 | // NOTE: this argument order is important for the MethodReader/MethodWriter | 22 | // NOTE: this argument order is important for the MethodReader/MethodWriter |
| 22 | public FieldEntry(ClassEntry classEntry, String name, Type type) { | 23 | public FieldEntry(ClassEntry classEntry, String name, Type type) { |
| 23 | if (classEntry == null) { | 24 | if (classEntry == null) { |
| 24 | throw new IllegalArgumentException("Class cannot be null!"); | 25 | throw new IllegalArgumentException("Class cannot be null!"); |
| 25 | } | 26 | } |
| 26 | if (name == null) { | 27 | if (name == null) { |
| 27 | throw new IllegalArgumentException("Field name cannot be null!"); | 28 | throw new IllegalArgumentException("Field name cannot be null!"); |
| 28 | } | 29 | } |
| 29 | if (type == null) { | 30 | if (type == null) { |
| 30 | throw new IllegalArgumentException("Field type cannot be null!"); | 31 | throw new IllegalArgumentException("Field type cannot be null!"); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | this.classEntry = classEntry; | 34 | this.classEntry = classEntry; |
| 34 | this.name = name; | 35 | this.name = name; |
| 35 | this.type = type; | 36 | this.type = type; |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | public FieldEntry(FieldEntry other, ClassEntry newClassEntry) { | 39 | public FieldEntry(FieldEntry other, ClassEntry newClassEntry) { |
| 39 | this.classEntry = newClassEntry; | 40 | this.classEntry = newClassEntry; |
| 40 | this.name = other.name; | 41 | this.name = other.name; |
| 41 | this.type = other.type; | 42 | this.type = other.type; |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | @Override | 45 | @Override |
| 45 | public ClassEntry getClassEntry() { | 46 | public ClassEntry getClassEntry() { |
| 46 | return this.classEntry; | 47 | return this.classEntry; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | @Override | 50 | @Override |
| 50 | public String getName() { | 51 | public String getName() { |
| 51 | return this.name; | 52 | return this.name; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | @Override | 55 | @Override |
| 55 | public String getClassName() { | 56 | public String getClassName() { |
| 56 | return this.classEntry.getName(); | 57 | return this.classEntry.getName(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | public Type getType() { | 60 | public Type getType() { |
| 60 | return this.type; | 61 | return this.type; |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | @Override | 64 | @Override |
| 64 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { | 65 | public FieldEntry cloneToNewClass(ClassEntry classEntry) { |
| 65 | return new FieldEntry(this, classEntry); | 66 | return new FieldEntry(this, classEntry); |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | @Override | 69 | @Override |
| 69 | public int hashCode() { | 70 | public int hashCode() { |
| 70 | return Utils.combineHashesOrdered(this.classEntry, this.name, this.type); | 71 | return Utils.combineHashesOrdered(this.classEntry, this.name, this.type); |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | @Override | 74 | @Override |
| 74 | public boolean equals(Object other) { | 75 | public boolean equals(Object other) { |
| 75 | return other instanceof FieldEntry && equals((FieldEntry) other); | 76 | return other instanceof FieldEntry && equals((FieldEntry) other); |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | public boolean equals(FieldEntry other) { | 79 | public boolean equals(FieldEntry other) { |
| 79 | return this.classEntry.equals(other.classEntry) && this.name.equals(other.name) && this.type.equals(other.type); | 80 | return this.classEntry.equals(other.classEntry) && this.name.equals(other.name) && this.type.equals(other.type); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | @Override | 83 | @Override |
| 83 | public String toString() { | 84 | public String toString() { |
| 84 | return this.classEntry.getName() + "." + this.name + ":" + this.type; | 85 | return this.classEntry.getName() + "." + this.name + ":" + this.type; |
| 85 | } | 86 | } |
| 86 | } | 87 | } |