From 4be005617b3b8c3578cca07c5d085d12916f0d1d Mon Sep 17 00:00:00 2001 From: lclc98 Date: Thu, 30 Jun 2016 00:49:21 +1000 Subject: Json format (#2) * Added new format * Fixed bug * Updated Version --- .../java/cuchaz/enigma/mapping/ClassEntry.java | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 src/main/java/cuchaz/enigma/mapping/ClassEntry.java (limited to 'src/main/java/cuchaz/enigma/mapping/ClassEntry.java') diff --git a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java new file mode 100644 index 0000000..2e7711b --- /dev/null +++ b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java @@ -0,0 +1,172 @@ +/******************************************************************************* + * Copyright (c) 2015 Jeff Martin. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public + * License v3.0 which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl.html + *
+ * Contributors:
+ * Jeff Martin - initial API and implementation
+ ******************************************************************************/
+package cuchaz.enigma.mapping;
+
+import com.google.common.collect.Lists;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class ClassEntry implements Entry, Serializable {
+
+ private static final long serialVersionUID = 4235460580973955811L;
+
+ private String m_name;
+
+ public ClassEntry(String className) {
+ if (className == null) {
+ throw new IllegalArgumentException("Class name cannot be null!");
+ }
+ if (className.indexOf('.') >= 0) {
+ throw new IllegalArgumentException("Class name must be in JVM format. ie, path/to/package/class$inner : " + className);
+ }
+
+ m_name = className;
+
+ if (isInnerClass() && getInnermostClassName().indexOf('/') >= 0) {
+ throw new IllegalArgumentException("Inner class must not have a package: " + className);
+ }
+ }
+
+ public ClassEntry(ClassEntry other) {
+ m_name = other.m_name;
+ }
+
+ @Override
+ public String getName() {
+ return m_name;
+ }
+
+ @Override
+ public String getClassName() {
+ return m_name;
+ }
+
+ @Override
+ public ClassEntry getClassEntry() {
+ return this;
+ }
+
+ @Override
+ public ClassEntry cloneToNewClass(ClassEntry classEntry) {
+ return classEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return m_name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof ClassEntry) {
+ return equals((ClassEntry) other);
+ }
+ return false;
+ }
+
+ public boolean equals(ClassEntry other) {
+ return m_name.equals(other.m_name);
+ }
+
+ @Override
+ public String toString() {
+ return m_name;
+ }
+
+ public boolean isInnerClass() {
+ return m_name.lastIndexOf('$') >= 0;
+ }
+
+ public List