package designPatternExtensions;
import models.dataSynchronizationModel.DataSynchronizationContext;
import models.dataSynchronizationModel.DataSynchronizationDesign;
import models.dataSynchronizationModel.IllegalRelationException;
import parser.JsonValue;
import parser.Parser;
import parser.Value;
import parser.exceptions.ExpectedArrayValue;
import parser.exceptions.ExpectedJsonValue;
import parser.exceptions.ExpectedStringValue;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class ModelLoader {
public static DataSynchronizationDesign load(String path) {
File file = new File(path);
try {
Parser parser = new Parser(new BufferedReader(new FileReader(file)));
Value jsonValue = parser.getValue();
DataSynchronizationDesign design;
return new DataSynchronizationDesign((JsonValue) jsonValue);
} catch (java.io.FileNotFoundException | ExpectedArrayValue
| ExpectedStringValue | ExpectedJsonValue e) {
throw new RuntimeException("Failed to load model: " + path, e);
} catch (IllegalRelationException e) {
throw new RuntimeException(e);
}
}
public static DataSynchronizationDesign load2(String path) {
File file = new File(path);
try {
Parser parser = new Parser(new BufferedReader(new FileReader(file)));
Value jsonValue = parser.getValue();
DataSynchronizationContext context = new DataSynchronizationContext(jsonValue);
return new DataSynchronizationDesign(context);
} catch (java.io.FileNotFoundException | ExpectedArrayValue
| ExpectedStringValue | ExpectedJsonValue e) {
throw new RuntimeException("Failed to load model: " + path, e);
} catch (IllegalRelationException e) {
throw new RuntimeException(e);
}
}
}