if (f.getName().endsWith(".class")) {
return new SingleFile(f);
} else if (f.isDirectory()) {
return new Folder(f);
} else if (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")) {
return new Archive(f);
} else {
throw new RuntimeException("File of wrong type: " + f.getName());
}
}