use of com.solinia.solinia.Models.SoliniaGod in project solinia3-core by mixxit.
the class SoliniaGodFactory method CreateGod.
public static ISoliniaGod CreateGod(String name) throws CoreStateInitException {
SoliniaGod entry = new SoliniaGod();
entry.setId(StateManager.getInstance().getConfigurationManager().getNextGodId());
entry.setName(name);
return StateManager.getInstance().getConfigurationManager().addGod(entry);
}
use of com.solinia.solinia.Models.SoliniaGod in project solinia3-core by mixxit.
the class JsonGodRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(Gods.values(), new TypeToken<List<SoliniaGod>>() {
}.getType());
try {
File file = new File(filePath);
if (!file.exists())
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
outWriter.append(jsonOutput);
outWriter.close();
fileOut.close();
System.out.println("Commited " + Gods.size() + " Gods");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations