Skip to content

Commit 8c8b045

Browse files
committed
Run Maven formatter
1 parent 52ea91b commit 8c8b045

14 files changed

+912
-502
lines changed

src/main/java/core/FileOperations.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
public class FileOperations {
1919

2020
public static enum FileExtension {
21-
ALL(""),
22-
HTML(".html"),
23-
JSON(".json"),
24-
JAVA(".java"),
25-
TEXT(".txt");
21+
ALL(""), HTML(".html"), JSON(".json"), JAVA(".java"), TEXT(".txt");
2622

2723
private final String extension;
24+
2825
FileExtension(String extension) {
2926
this.extension = extension;
3027
}
28+
3129
public String getExtension() {
3230
return extension;
3331
}
@@ -37,52 +35,64 @@ public static class ScannerUtil {
3735
public static Scanner createScanner(InputStream inputStream) {
3836
return new Scanner(inputStream, StandardCharsets.UTF_8);
3937
}
38+
4039
public static Scanner createScanner(File file) throws IOException {
4140
return new Scanner(file, StandardCharsets.UTF_8);
4241
}
4342
}
4443

4544
/**
46-
* Returns a Set of Paths for all the files in the specified directory.
47-
* <p>Equivalent to {@link FileOperations#listFiles(Path, FileExtension) listFiles(dir, FileExtension.ALL)}
45+
* Returns a Set of Paths for all the files in the specified directory.
46+
* <p>
47+
* Equivalent to {@link FileOperations#listFiles(Path, FileExtension) listFiles(dir, FileExtension.ALL)}
48+
*
49+
* @param dir
50+
* The path to the directory to list the files within
4851
*
49-
* @param dir The path to the directory to list the files within
5052
* @return A Set of Paths to each file within the directory
51-
* @throws IOException If the directory path is invalid or unable to be located
53+
*
54+
* @throws IOException
55+
* If the directory path is invalid or unable to be located
56+
*
5257
* @see FileExtension#ALL
5358
*/
5459
public static Set<Path> listFiles(Path dir) throws IOException {
5560
try {
5661
Set<Path> pathSet = listFiles(dir, FileExtension.ALL);
5762
return pathSet;
58-
}
59-
catch (IOException e) {
63+
} catch (IOException e) {
6064
throw e;
6165
}
6266
}
6367

6468
/**
6569
* Returns a Set of Paths for all the files in the specificed directory with the given extension.
66-
*
67-
* @param dir The path to the directory to list the files within.
68-
* @param extension A FileOperations.FileExtension to filter the Path results by.
70+
*
71+
* @param dir
72+
* The path to the directory to list the files within.
73+
* @param extension
74+
* A FileOperations.FileExtension to filter the Path results by.
75+
*
6976
* @return A Set of Paths to each file within the directory with the extension.
70-
* @throws IOException If the directory path is invalid or unable to be located.
77+
*
78+
* @throws IOException
79+
* If the directory path is invalid or unable to be located.
7180
*/
7281
public static Set<Path> listFiles(Path dir, FileExtension extension) throws IOException {
7382
Set<Path> pathSet = new HashSet<>();
7483
dir = dir.normalize();
75-
if(!Files.exists(dir)) throw new IOException("The specified path, " + dir.toString() + ", was not found.");
84+
if (!Files.exists(dir))
85+
throw new IOException("The specified path, " + dir.toString() + ", was not found.");
7686
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
7787
for (Path path : stream) {
7888
String fileName = path.getFileName().toString();
79-
if (!Files.isDirectory(path) && !FilePaths.IGNORED_FILES.contains(fileName) && fileName.endsWith(extension.getExtension())) {
89+
if (!Files.isDirectory(path) && !FilePaths.IGNORED_FILES.contains(fileName)
90+
&& fileName.endsWith(extension.getExtension())) {
8091
pathSet.add(dir.resolve(fileName));
8192
}
8293
}
8394
return pathSet;
84-
}
85-
catch (IOException e) {
95+
} catch (IOException e) {
8696
System.out.println("Error accessing directory: " + dir);
8797
throw e;
8898
}
@@ -111,8 +121,7 @@ public static List<String> readFile(Path path) {
111121
result.add(scanner.nextLine());
112122
}
113123
return result;
114-
}
115-
catch (IOException e) {
124+
} catch (IOException e) {
116125
e.printStackTrace();
117126
return null;
118127
}
@@ -121,6 +130,7 @@ public static List<String> readFile(Path path) {
121130
public static void writeFile(String filename, String extension, Path destination, String content) {
122131
writeFile(filename, extension, destination, Collections.singletonList(content));
123132
}
133+
124134
public static void writeFile(String filename, String extension, Path destination, List<String> content) {
125135
Path filePath = destination.resolve(filename + extension);
126136
File file = filePath.toFile();

src/main/java/core/FilePaths.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.nio.file.Path;
55

66
public class FilePaths {
7-
7+
88
public static final Path ROOT_PATH = Path.of("JSON-JAVA-OBJECTIFIER");
99
public static final Path CORE_PATH = Path.of("src/main/core");
1010
public static final Path DATA_SOURCE = Path.of("data");

0 commit comments

Comments
 (0)