Modification de repository
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package lightcontainer.storage;
|
||||
|
||||
public interface Adapter {
|
||||
|
||||
String toString();
|
||||
|
||||
String toString(AppData appData);
|
||||
|
||||
AppData fromString(String appDataString);
|
||||
}
|
||||
|
||||
@@ -9,18 +9,11 @@ import java.util.*;
|
||||
*/
|
||||
public class JsonAdapter implements Adapter {
|
||||
|
||||
private AppData appData;
|
||||
|
||||
public JsonAdapter(AppData appData) {
|
||||
this.appData = appData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A Json String containing AppData properties
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString(AppData appData) {
|
||||
return addData(appData);
|
||||
}
|
||||
|
||||
@@ -77,7 +70,6 @@ public class JsonAdapter implements Adapter {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param appDataString The Json String to convert
|
||||
* @return An AppData instance
|
||||
*/
|
||||
@@ -100,8 +92,7 @@ public class JsonAdapter implements Adapter {
|
||||
for (User user : users) {
|
||||
appData.addUser(user.getName(), user.getPassword(), user.getAesKey());
|
||||
}
|
||||
this.appData = appData;
|
||||
return this.appData;
|
||||
return appData;
|
||||
} catch (JsonParseException parseException) {
|
||||
System.out.println("[FFE] : Error while loading configuration file"); //TODO - changer en log
|
||||
return null;
|
||||
|
||||
@@ -12,13 +12,15 @@ public class Repository {
|
||||
|
||||
private final String filePath;
|
||||
private final Adapter adapter;
|
||||
private final AppData appData;
|
||||
|
||||
/**
|
||||
* @param filePath The path to the configuration file
|
||||
* @param adapter The adapter that converts objects to string and vice-versa
|
||||
*/
|
||||
public Repository(String filePath, Adapter adapter) {
|
||||
public Repository(String filePath, AppData appData, Adapter adapter) {
|
||||
this.filePath = filePath;
|
||||
this.appData = appData;
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user