Skip to content

Commit b18bc95

Browse files
committed
Even more applications of the Law of Demeter
1 parent 0d7b7c5 commit b18bc95

36 files changed

Lines changed: 94 additions & 78 deletions

src/main/java/me/konloch/kontainer/io/DiskReader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.FileReader;
66
import java.util.ArrayList;
77
import java.util.HashMap;
8+
import java.util.List;
89
import java.util.Map;
910
import java.util.Random;
1011
import the.bytecode.club.bytecodeviewer.util.EncodeUtils;
@@ -18,14 +19,14 @@
1819
public class DiskReader {
1920

2021
public static Random random = new Random();
21-
public static Map<String, ArrayList<String>> map = new HashMap<>();
22+
public static Map<String, List<String>> map = new HashMap<>();
2223

2324
/**
2425
* Used to load from file, allows caching
2526
*/
26-
public synchronized static ArrayList<String> loadArrayList(String fileName,
27-
boolean cache) {
28-
ArrayList<String> array = new ArrayList<>();
27+
public synchronized static List<String> loadArrayList(String fileName,
28+
boolean cache) {
29+
List<String> array = new ArrayList<>();
2930
if (!map.containsKey(fileName)) {
3031
try {
3132
File file = new File(fileName);
@@ -76,7 +77,7 @@ public synchronized static String loadAsString(String fileName) throws Exception
7677
public static String loadString(String fileName, int lineNumber,
7778
boolean cache) throws Exception {
7879

79-
ArrayList<String> array;
80+
List<String> array;
8081
if (!map.containsKey(fileName)) {
8182
array = new ArrayList<>();
8283
File file = new File(fileName);

src/main/java/me/konloch/kontainer/io/HTTPRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void setup() throws Exception {
142142
* @throws Exception
143143
*/
144144
public String[] read() throws Exception {
145-
ArrayList<String> st;
145+
List<String> st;
146146

147147
try {
148148
setup();
@@ -172,7 +172,7 @@ public String[] read() throws Exception {
172172
* @throws Exception
173173
*/
174174
public String[] read(int linesToRead) throws Exception {
175-
ArrayList<String> st;
175+
List<String> st;
176176

177177
try {
178178
setup();
@@ -273,4 +273,4 @@ private void cleanup() {
273273
connection = null;
274274
}
275275

276-
}
276+
}

src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ public static byte[] getClassFileBytes(Class<?> clazz) throws IOException
432432
* @return the loaded classes as an array list
433433
*/
434434
@Deprecated
435-
public static ArrayList<ClassNode> getLoadedClasses()
435+
public static List<ClassNode> getLoadedClasses()
436436
{
437-
ArrayList<ClassNode> a = new ArrayList<>();
437+
List<ClassNode> a = new ArrayList<>();
438438

439439
for (ResourceContainer container : resourceContainers.values())
440440
for (ClassNode c : container.resourceClasses.values())

src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public static ClassNode getClassNode(String name) {
189189
*
190190
* @return the loaded classes
191191
*/
192-
public static ArrayList<ClassNode> getLoadedClasses() {
192+
public static List<ClassNode> getLoadedClasses() {
193193
return the.bytecode.club.bytecodeviewer.BytecodeViewer
194194
.getLoadedClasses();
195195
}

src/main/java/the/bytecode/club/bytecodeviewer/api/ClassNodeLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.ArrayList;
99
import java.util.Collection;
1010
import java.util.HashMap;
11+
import java.util.List;
1112
import java.util.Map;
1213
import org.objectweb.asm.ClassWriter;
1314
import org.objectweb.asm.tree.ClassNode;
@@ -73,7 +74,7 @@ public void clear() {
7374
* @return All classes in this loader
7475
*/
7576
public Collection<Class<?>> getAllClasses() {
76-
ArrayList<Class<?>> classes = new ArrayList<>();
77+
List<Class<?>> classes = new ArrayList<>();
7778
for (String s : this.classes.keySet()) {
7879
try {
7980
classes.add(loadClass(s));

src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package the.bytecode.club.bytecodeviewer.api;
22

33
import java.util.ArrayList;
4+
import java.util.List;
45
import org.objectweb.asm.tree.ClassNode;
56
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
67
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
@@ -94,5 +95,5 @@ public void executeContainer()
9495
*
9596
* @param classNodeList all of the loaded classes for easy access.
9697
*/
97-
public abstract void execute(ArrayList<ClassNode> classNodeList);
98+
public abstract void execute(List<ClassNode> classNodeList);
9899
}

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
public class ClassNodeDecompiler
3939
{
4040
public static PrefixedStringBuilder decompile(
41-
PrefixedStringBuilder sb, ArrayList<String> decompiledClasses,
41+
PrefixedStringBuilder sb, List<String> decompiledClasses,
4242
ClassNode cn) {
43-
ArrayList<String> unableToDecompile = new ArrayList<>();
43+
List<String> unableToDecompile = new ArrayList<>();
4444
decompiledClasses.add(cn.name);
4545
sb.append(getAccessString(cn.access));
4646
sb.append(" ");

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class InstructionPrinter {
6969
protected List<AbstractInsnNode> matchedInsns;
7070
protected Map<LabelNode, Integer> labels;
7171
private boolean firstLabel = false;
72-
private final ArrayList<String> info = new ArrayList<>();
72+
private final List<String> info = new ArrayList<>();
7373

7474
public InstructionPrinter(MethodNode m, TypeAndName[] args) {
7575
this.args = args;
@@ -99,7 +99,7 @@ public InstructionPrinter(MethodNode m, InstructionPattern pattern,
9999
*
100100
* @return The print as an ArrayList
101101
*/
102-
public ArrayList<String> createPrint() {
102+
public List<String> createPrint() {
103103
firstLabel = false;
104104
info.clear();
105105
for (AbstractInsnNode ain : mNode.instructions) {

src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public class MainViewerGUI extends JFrame
110110
public final List<JMenuItem> waitIcons = new ArrayList<>();
111111

112112
//main UI components
113-
public final ArrayList<VisibleComponent> uiComponents = new ArrayList<>();
113+
public final List<VisibleComponent> uiComponents = new ArrayList<>();
114114
public final Workspace workPane = new Workspace();
115115
public final ResourceListPane resourcePane = new ResourceListPane();
116116
public final SearchBoxPane searchBoxPane = new SearchBoxPane();
@@ -915,7 +915,7 @@ public void reloadResources()
915915
if (dialog.promptChoice() == 0)
916916
{
917917
LazyNameUtil.reset();
918-
ArrayList<File> reopen = new ArrayList<>();
918+
List<File> reopen = new ArrayList<>();
919919

920920
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
921921
{

src/main/java/the/bytecode/club/bytecodeviewer/gui/components/FileChooser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.util.Arrays;
55
import java.util.HashSet;
6+
import java.util.Set;
67
import javax.swing.JFileChooser;
78
import javax.swing.filechooser.FileFilter;
89
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@@ -40,7 +41,7 @@ public FileChooser(File file, String title, String description, String... extens
4041

4142
public FileChooser(boolean skipFileFilter, File file, String title, String description, String... extensions)
4243
{
43-
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
44+
Set<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
4445

4546
try {
4647
if(file.isDirectory())

0 commit comments

Comments
 (0)