mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-24 00:24:42 +00:00
Java 11 migrate c-d (remaining) (#1111)
* Moves converter pattern to Java 11 * Moves cqrs pattern to Java 11 * Moves dao pattern to Java 11 * Moves data-bus pattern to Java 11 * Moves data-locality pattern to Java 11 * Moves data-mapper pattern to Java 11 * Moves data-transfer-object pattern to Java 11 * Moves decorator pattern to Java 11 * Moves delegation pattern to Java 11 * Moves dependency-injection to Java 11 * Moves dirty-flag to Java 11 * Moves double-buffer to Java 11 * Moves double-checked-locking to Java 11 * Moves double-dispatch to Java 11 * Corrects with changes thats breaking test cases
This commit is contained in:
committed by
Ilkka Seppälä
parent
5681684157
commit
ea57934db6
@@ -27,8 +27,8 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -62,24 +62,18 @@ public class DataFetcher {
|
||||
* @return List of strings
|
||||
*/
|
||||
public List<String> fetch() {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
File file = new File(classLoader.getResource(filename).getFile());
|
||||
var classLoader = getClass().getClassLoader();
|
||||
var file = new File(classLoader.getResource(filename).getFile());
|
||||
|
||||
if (isDirty(file.lastModified())) {
|
||||
LOGGER.info(filename + " is dirty! Re-fetching file content...");
|
||||
|
||||
List<String> data = new ArrayList<String>();
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
data.add(line);
|
||||
}
|
||||
try (var br = new BufferedReader(new FileReader(file))) {
|
||||
return br.lines().collect(Collectors.collectingAndThen(Collectors.toList(), List::copyOf));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
return new ArrayList<String>();
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user