package utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import java.io.*;
import java.lang.reflect.Type;
import java.util.List;


/**
 * Created by Gondr on 19/05/2017.
 */
public abstract class Serialiser {
    protected static Gson gson = new GsonBuilder().create();

    protected boolean serialise(List list, String filepath){
        try{
            String path = getClass().getClassLoader().getResource(filepath).getPath();
            Writer writer = new OutputStreamWriter(new FileOutputStream(path), "UTF-8");
            gson.toJson(list, writer);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

}
