Search in sources :

Example 1 with SoliniaAAAbility

use of com.solinia.solinia.Models.SoliniaAAAbility in project solinia3-core by mixxit.

the class JsonAAAbilityRepository method commit.

@Override
public void commit() {
    // TODO Auto-generated method stub
    GsonBuilder gsonbuilder = new GsonBuilder();
    // gsonbuilder.setPrettyPrinting();
    gsonbuilder.registerTypeAdapterFactory(new ISoliniaAARankTypeAdapterFactory(SoliniaAARank.class));
    gsonbuilder.registerTypeAdapterFactory(new ISoliniaAAEffectTypeAdapterFactory(SoliniaAAEffect.class));
    Gson gson = gsonbuilder.create();
    String jsonOutput = gson.toJson(aaabilities.values(), new TypeToken<List<SoliniaAAAbility>>() {
    }.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 " + aaabilities.size() + " AA abilities");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) FileNotFoundException(java.io.FileNotFoundException) Gson(com.google.gson.Gson) ISoliniaAARankTypeAdapterFactory(com.solinia.solinia.Factories.ISoliniaAARankTypeAdapterFactory) IOException(java.io.IOException) SoliniaAAEffect(com.solinia.solinia.Models.SoliniaAAEffect) ISoliniaAAEffectTypeAdapterFactory(com.solinia.solinia.Factories.ISoliniaAAEffectTypeAdapterFactory) ISoliniaAAAbility(com.solinia.solinia.Interfaces.ISoliniaAAAbility) SoliniaAAAbility(com.solinia.solinia.Models.SoliniaAAAbility) TypeToken(com.google.gson.reflect.TypeToken) FileOutputStream(java.io.FileOutputStream) SoliniaAARank(com.solinia.solinia.Models.SoliniaAARank) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 ISoliniaAAEffectTypeAdapterFactory (com.solinia.solinia.Factories.ISoliniaAAEffectTypeAdapterFactory)1 ISoliniaAARankTypeAdapterFactory (com.solinia.solinia.Factories.ISoliniaAARankTypeAdapterFactory)1 ISoliniaAAAbility (com.solinia.solinia.Interfaces.ISoliniaAAAbility)1 SoliniaAAAbility (com.solinia.solinia.Models.SoliniaAAAbility)1 SoliniaAAEffect (com.solinia.solinia.Models.SoliniaAAEffect)1 SoliniaAARank (com.solinia.solinia.Models.SoliniaAARank)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1