Sauvegarde et lecture du fichier de synchronisation -> changement de structure pour une meilleur découpe des responsabilités

This commit is contained in:
Maximilien LEDOUX 2022-03-05 17:48:56 +01:00
parent 0161077cdd
commit a185a3ecb7
6 changed files with 36 additions and 4 deletions

View File

@ -0,0 +1,6 @@
package lightcontainer.storage;
public interface FileReader {
AppData readFile(String fileName);
}

View File

@ -0,0 +1,6 @@
package lightcontainer.storage;
public interface FileWriter {
void writeToFile(String fileName, AppData appData);
}

View File

@ -0,0 +1,9 @@
package lightcontainer.storage;
public class JsonReader implements FileReader {
@Override
public AppData readFile(String fileName) {
return null;
}
}

View File

@ -4,12 +4,14 @@ public class JsonRepository implements Repository {
@Override
public void save(String fileName, AppData data) {
public void save(FileWriter fileWriter) {
}
@Override
public AppData load(String fileName) {
public AppData load(FileReader fileReader) {
return null;
}
}

View File

@ -0,0 +1,9 @@
package lightcontainer.storage;
public class JsonWriter implements FileWriter {
@Override
public void writeToFile(String fileName, AppData appData) {
}
}

View File

@ -2,7 +2,7 @@ package lightcontainer.storage;
public interface Repository {
void save(String fileName, AppData data);
void save(FileWriter fileWriter);
AppData load(String fileName);
AppData load(FileReader fileReader);
}