diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/ClassEntry.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/ClassEntry.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java index 788811f..a49f8dd 100644 --- a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java | |||
| @@ -11,18 +11,18 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.mapping; | 12 | package cuchaz.enigma.mapping; |
| 13 | 13 | ||
| 14 | import com.google.common.base.Preconditions; | ||
| 14 | import com.google.common.collect.Lists; | 15 | import com.google.common.collect.Lists; |
| 15 | 16 | ||
| 16 | import java.util.List; | 17 | import java.util.List; |
| 17 | 18 | ||
| 18 | public class ClassEntry implements Entry { | 19 | public class ClassEntry implements Entry { |
| 19 | 20 | ||
| 20 | private String name; | 21 | private final String name; |
| 21 | 22 | ||
| 22 | public ClassEntry(String className) { | 23 | public ClassEntry(String className) { |
| 23 | if (className == null) { | 24 | Preconditions.checkNotNull(className, "Class name cannot be null"); |
| 24 | throw new IllegalArgumentException("Class name cannot be null!"); | 25 | |
| 25 | } | ||
| 26 | if (className.indexOf('.') >= 0) { | 26 | if (className.indexOf('.') >= 0) { |
| 27 | throw new IllegalArgumentException("Class name must be in JVM format. ie, path/to/package/class$inner : " + className); | 27 | throw new IllegalArgumentException("Class name must be in JVM format. ie, path/to/package/class$inner : " + className); |
| 28 | } | 28 | } |
| @@ -49,12 +49,12 @@ public class ClassEntry implements Entry { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
| 52 | public ClassEntry getClassEntry() { | 52 | public ClassEntry getOwnerClassEntry() { |
| 53 | return this; | 53 | return this; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | @Override | 56 | @Override |
| 57 | public ClassEntry cloneToNewClass(ClassEntry classEntry) { | 57 | public ClassEntry updateOwnership(ClassEntry classEntry) { |
| 58 | return classEntry; | 58 | return classEntry; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -132,11 +132,7 @@ public class ClassEntry implements Entry { | |||
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | public String getPackageName() { | 134 | public String getPackageName() { |
| 135 | int pos = this.name.lastIndexOf('/'); | 135 | return getPackageName(this.name); |
| 136 | if (pos > 0) { | ||
| 137 | return this.name.substring(0, pos); | ||
| 138 | } | ||
| 139 | return null; | ||
| 140 | } | 136 | } |
| 141 | 137 | ||
| 142 | public String getSimpleName() { | 138 | public String getSimpleName() { |
| @@ -147,6 +143,14 @@ public class ClassEntry implements Entry { | |||
| 147 | return this.name; | 143 | return this.name; |
| 148 | } | 144 | } |
| 149 | 145 | ||
| 146 | public static String getPackageName(String name) { | ||
| 147 | int pos = name.lastIndexOf('/'); | ||
| 148 | if (pos > 0) { | ||
| 149 | return name.substring(0, pos); | ||
| 150 | } | ||
| 151 | return null; | ||
| 152 | } | ||
| 153 | |||
| 150 | public ClassEntry buildClassEntry(List<ClassEntry> classChain) { | 154 | public ClassEntry buildClassEntry(List<ClassEntry> classChain) { |
| 151 | assert (classChain.contains(this)); | 155 | assert (classChain.contains(this)); |
| 152 | StringBuilder buf = new StringBuilder(); | 156 | StringBuilder buf = new StringBuilder(); |