summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java')
-rw-r--r--src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java
deleted file mode 100644
index 7904c5f..0000000
--- a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java
+++ /dev/null
@@ -1,72 +0,0 @@
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 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.analysis;
13
14import com.google.common.collect.Lists;
15import cuchaz.enigma.analysis.index.InheritanceIndex;
16import cuchaz.enigma.translation.Translator;
17import cuchaz.enigma.translation.representation.entry.ClassEntry;
18
19import javax.swing.tree.DefaultMutableTreeNode;
20import java.util.List;
21
22public class ClassInheritanceTreeNode extends DefaultMutableTreeNode {
23 private final Translator translator;
24 private final ClassEntry obfClassEntry;
25
26 public ClassInheritanceTreeNode(Translator translator, String obfClassName) {
27 this.translator = translator;
28 this.obfClassEntry = new ClassEntry(obfClassName);
29 }
30
31 public static ClassInheritanceTreeNode findNode(ClassInheritanceTreeNode node, ClassEntry entry) {
32 // is this the node?
33 if (node.getObfClassName().equals(entry.getFullName())) {
34 return node;
35 }
36
37 // recurse
38 for (int i = 0; i < node.getChildCount(); i++) {
39 ClassInheritanceTreeNode foundNode = findNode((ClassInheritanceTreeNode) node.getChildAt(i), entry);
40 if (foundNode != null) {
41 return foundNode;
42 }
43 }
44 return null;
45 }
46
47 public String getObfClassName() {
48 return this.obfClassEntry.getFullName();
49 }
50
51 @Override
52 public String toString() {
53 return translator.translate(obfClassEntry).getFullName();
54 }
55
56 public void load(InheritanceIndex ancestries, boolean recurse) {
57 // get all the child nodes
58 List<ClassInheritanceTreeNode> nodes = Lists.newArrayList();
59 for (ClassEntry inheritor : ancestries.getChildren(this.obfClassEntry)) {
60 nodes.add(new ClassInheritanceTreeNode(translator, inheritor.getFullName()));
61 }
62
63 // add them to this node
64 nodes.forEach(this::add);
65
66 if (recurse) {
67 for (ClassInheritanceTreeNode node : nodes) {
68 node.load(ancestries, true);
69 }
70 }
71 }
72}