diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/ClassEntry.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/ClassEntry.java | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java index c9304d4..a58d054 100644 --- a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java | |||
| @@ -12,14 +12,11 @@ package cuchaz.enigma.mapping; | |||
| 12 | 12 | ||
| 13 | import com.google.common.collect.Lists; | 13 | import com.google.common.collect.Lists; |
| 14 | 14 | ||
| 15 | import java.io.Serializable; | ||
| 16 | import java.util.List; | 15 | import java.util.List; |
| 17 | 16 | ||
| 18 | public class ClassEntry implements Entry, Serializable { | 17 | public class ClassEntry implements Entry { |
| 19 | 18 | ||
| 20 | private static final long serialVersionUID = 4235460580973955811L; | 19 | private String name; |
| 21 | |||
| 22 | private String m_name; | ||
| 23 | 20 | ||
| 24 | public ClassEntry(String className) { | 21 | public ClassEntry(String className) { |
| 25 | if (className == null) { | 22 | if (className == null) { |
| @@ -29,7 +26,7 @@ public class ClassEntry implements Entry, Serializable { | |||
| 29 | throw new IllegalArgumentException("Class name must be in JVM format. ie, path/to/package/class$inner : " + className); | 26 | throw new IllegalArgumentException("Class name must be in JVM format. ie, path/to/package/class$inner : " + className); |
| 30 | } | 27 | } |
| 31 | 28 | ||
| 32 | m_name = className; | 29 | this.name = className; |
| 33 | 30 | ||
| 34 | if (isInnerClass() && getInnermostClassName().indexOf('/') >= 0) { | 31 | if (isInnerClass() && getInnermostClassName().indexOf('/') >= 0) { |
| 35 | throw new IllegalArgumentException("Inner class must not have a package: " + className); | 32 | throw new IllegalArgumentException("Inner class must not have a package: " + className); |
| @@ -37,17 +34,17 @@ public class ClassEntry implements Entry, Serializable { | |||
| 37 | } | 34 | } |
| 38 | 35 | ||
| 39 | public ClassEntry(ClassEntry other) { | 36 | public ClassEntry(ClassEntry other) { |
| 40 | m_name = other.m_name; | 37 | this.name = other.name; |
| 41 | } | 38 | } |
| 42 | 39 | ||
| 43 | @Override | 40 | @Override |
| 44 | public String getName() { | 41 | public String getName() { |
| 45 | return m_name; | 42 | return this.name; |
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | @Override | 45 | @Override |
| 49 | public String getClassName() { | 46 | public String getClassName() { |
| 50 | return m_name; | 47 | return this.name; |
| 51 | } | 48 | } |
| 52 | 49 | ||
| 53 | @Override | 50 | @Override |
| @@ -62,7 +59,7 @@ public class ClassEntry implements Entry, Serializable { | |||
| 62 | 59 | ||
| 63 | @Override | 60 | @Override |
| 64 | public int hashCode() { | 61 | public int hashCode() { |
| 65 | return m_name.hashCode(); | 62 | return this.name.hashCode(); |
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | @Override | 65 | @Override |
| @@ -71,20 +68,20 @@ public class ClassEntry implements Entry, Serializable { | |||
| 71 | } | 68 | } |
| 72 | 69 | ||
| 73 | public boolean equals(ClassEntry other) { | 70 | public boolean equals(ClassEntry other) { |
| 74 | return m_name.equals(other.m_name); | 71 | return this.name.equals(other.name); |
| 75 | } | 72 | } |
| 76 | 73 | ||
| 77 | @Override | 74 | @Override |
| 78 | public String toString() { | 75 | public String toString() { |
| 79 | return m_name; | 76 | return this.name; |
| 80 | } | 77 | } |
| 81 | 78 | ||
| 82 | public boolean isInnerClass() { | 79 | public boolean isInnerClass() { |
| 83 | return m_name.lastIndexOf('$') >= 0; | 80 | return this.name.lastIndexOf('$') >= 0; |
| 84 | } | 81 | } |
| 85 | 82 | ||
| 86 | public List<String> getClassChainNames() { | 83 | public List<String> getClassChainNames() { |
| 87 | return Lists.newArrayList(m_name.split("\\$")); | 84 | return Lists.newArrayList(this.name.split("\\$")); |
| 88 | } | 85 | } |
| 89 | 86 | ||
| 90 | public List<ClassEntry> getClassChain() { | 87 | public List<ClassEntry> getClassChain() { |
| @@ -102,9 +99,9 @@ public class ClassEntry implements Entry, Serializable { | |||
| 102 | 99 | ||
| 103 | public String getOutermostClassName() { | 100 | public String getOutermostClassName() { |
| 104 | if (isInnerClass()) { | 101 | if (isInnerClass()) { |
| 105 | return m_name.substring(0, m_name.indexOf('$')); | 102 | return this.name.substring(0, this.name.indexOf('$')); |
| 106 | } | 103 | } |
| 107 | return m_name; | 104 | return this.name; |
| 108 | } | 105 | } |
| 109 | 106 | ||
| 110 | public ClassEntry getOutermostClassEntry() { | 107 | public ClassEntry getOutermostClassEntry() { |
| @@ -115,7 +112,7 @@ public class ClassEntry implements Entry, Serializable { | |||
| 115 | if (!isInnerClass()) { | 112 | if (!isInnerClass()) { |
| 116 | throw new Error("This is not an inner class!"); | 113 | throw new Error("This is not an inner class!"); |
| 117 | } | 114 | } |
| 118 | return m_name.substring(0, m_name.lastIndexOf('$')); | 115 | return this.name.substring(0, this.name.lastIndexOf('$')); |
| 119 | } | 116 | } |
| 120 | 117 | ||
| 121 | public ClassEntry getOuterClassEntry() { | 118 | public ClassEntry getOuterClassEntry() { |
| @@ -126,27 +123,27 @@ public class ClassEntry implements Entry, Serializable { | |||
| 126 | if (!isInnerClass()) { | 123 | if (!isInnerClass()) { |
| 127 | throw new Error("This is not an inner class!"); | 124 | throw new Error("This is not an inner class!"); |
| 128 | } | 125 | } |
| 129 | return m_name.substring(m_name.lastIndexOf('$') + 1); | 126 | return this.name.substring(this.name.lastIndexOf('$') + 1); |
| 130 | } | 127 | } |
| 131 | 128 | ||
| 132 | public boolean isInDefaultPackage() { | 129 | public boolean isInDefaultPackage() { |
| 133 | return m_name.indexOf('/') < 0; | 130 | return this.name.indexOf('/') < 0; |
| 134 | } | 131 | } |
| 135 | 132 | ||
| 136 | public String getPackageName() { | 133 | public String getPackageName() { |
| 137 | int pos = m_name.lastIndexOf('/'); | 134 | int pos = this.name.lastIndexOf('/'); |
| 138 | if (pos > 0) { | 135 | if (pos > 0) { |
| 139 | return m_name.substring(0, pos); | 136 | return this.name.substring(0, pos); |
| 140 | } | 137 | } |
| 141 | return null; | 138 | return null; |
| 142 | } | 139 | } |
| 143 | 140 | ||
| 144 | public String getSimpleName() { | 141 | public String getSimpleName() { |
| 145 | int pos = m_name.lastIndexOf('/'); | 142 | int pos = this.name.lastIndexOf('/'); |
| 146 | if (pos > 0) { | 143 | if (pos > 0) { |
| 147 | return m_name.substring(pos + 1); | 144 | return this.name.substring(pos + 1); |
| 148 | } | 145 | } |
| 149 | return m_name; | 146 | return this.name; |
| 150 | } | 147 | } |
| 151 | 148 | ||
| 152 | public ClassEntry buildClassEntry(List<ClassEntry> classChain) { | 149 | public ClassEntry buildClassEntry(List<ClassEntry> classChain) { |