// Path: app/src/main/java/io/rapidpro/surveyor/utils/JsonUtils.java
// public class JsonUtils {
//     private static Gson s_gson = new GsonBuilder()
//             //.setPrettyPrinting()
//             .registerTypeAdapter(RawJson.class, new RawJson.Adapter())
//             .create();
// 
//     public static Gson getGson() {
//         return s_gson;
//     }
// 
//     public static String marshal(Object src) {
//         return s_gson.toJson(src);
//     }
// 
//     public static <T> T unmarshal(String json, Class<T> clazz) {
//         return s_gson.fromJson(json, clazz);
//     }
// 
//     public static <T> T unmarshal(String json, TypeToken type) {
//         return s_gson.fromJson(json, type.getType());
//     }
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/utils/RawJson.java
// public class RawJson {
//     private String data;
// 
//     public RawJson(String data) {
//         this.data = data;
//     }
// 
//     @Override
//     public String toString() {
//         return this.data;
//     }
// 
//     /**
//      * Type adapter to tell Gson how to use fields of this type
//      */
//     public static class Adapter extends TypeAdapter<RawJson> {
//         @Override
//         public void write(JsonWriter out, RawJson value) throws IOException {
//             out.jsonValue(value.toString());
//         }
// 
//         @Override
//         public RawJson read(JsonReader in) throws IOException {
//             // TODO ideally this wouldn't parse the entire tree into memory
//             // see https://github.com/google/gson/issues/1368
//             JsonElement parsed = new JsonParser().parse(in);
// 
//             return new RawJson(parsed.toString());
//         }
//     }
// }


import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import com.nyaruka.goflow.mobile.FlowReference;
import io.rapidpro.surveyor.utils.JsonUtils;
import io.rapidpro.surveyor.utils.RawJson;
package io.rapidpro.surveyor.data;



public class Flow {
    private String uuid;

    private String name;

    @SerializedName("spec_version")
    private String specVersion;

    private int revision;

    @SerializedName("question_count")
    private int questionCount;

    /**
     * Creates a new flow
     *
     * @param uuid          the flow UUID
     * @param name          the flow name
     * @param specVersion   the flow spec version number
     * @param revision      the flow revision number
     * @param questionCount the number of questions
     */
    public Flow(String uuid, String name, String specVersion, int revision, int questionCount) {
        this.uuid = uuid;
        this.name = name;
        this.specVersion = specVersion;
        this.revision = revision;
        this.questionCount = questionCount;
    }

    /**
     * Extracts a flow summary from the given flow definition
     *
     * @param flow the flow definition
     * @return the flow summary
     */
// Path: app/src/main/java/io/rapidpro/surveyor/utils/JsonUtils.java
// public class JsonUtils {
//     private static Gson s_gson = new GsonBuilder()
//             //.setPrettyPrinting()
//             .registerTypeAdapter(RawJson.class, new RawJson.Adapter())
//             .create();
// 
//     public static Gson getGson() {
//         return s_gson;
//     }
// 
//     public static String marshal(Object src) {
//         return s_gson.toJson(src);
//     }
// 
//     public static <T> T unmarshal(String json, Class<T> clazz) {
//         return s_gson.fromJson(json, clazz);
//     }
// 
//     public static <T> T unmarshal(String json, TypeToken type) {
//         return s_gson.fromJson(json, type.getType());
//     }
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/utils/RawJson.java
// public class RawJson {
//     private String data;
// 
//     public RawJson(String data) {
//         this.data = data;
//     }
// 
//     @Override
//     public String toString() {
//         return this.data;
//     }
// 
//     /**
//      * Type adapter to tell Gson how to use fields of this type
//      */
//     public static class Adapter extends TypeAdapter<RawJson> {
//         @Override
//         public void write(JsonWriter out, RawJson value) throws IOException {
//             out.jsonValue(value.toString());
//         }
// 
//         @Override
//         public RawJson read(JsonReader in) throws IOException {
//             // TODO ideally this wouldn't parse the entire tree into memory
//             // see https://github.com/google/gson/issues/1368
//             JsonElement parsed = new JsonParser().parse(in);
// 
//             return new RawJson(parsed.toString());
//         }
//     }
// }


// Path: app/src/main/java/io/rapidpro/surveyor/data/Flow.java
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import com.nyaruka.goflow.mobile.FlowReference;
import io.rapidpro.surveyor.utils.JsonUtils;
import io.rapidpro.surveyor.utils.RawJson;

package io.rapidpro.surveyor.data;



public class Flow {
    private String uuid;

    private String name;

    @SerializedName("spec_version")
    private String specVersion;

    private int revision;

    @SerializedName("question_count")
    private int questionCount;

    /**
     * Creates a new flow
     *
     * @param uuid          the flow UUID
     * @param name          the flow name
     * @param specVersion   the flow spec version number
     * @param revision      the flow revision number
     * @param questionCount the number of questions
     */
    public Flow(String uuid, String name, String specVersion, int revision, int questionCount) {
        this.uuid = uuid;
        this.name = name;
        this.specVersion = specVersion;
        this.revision = revision;
        this.questionCount = questionCount;
    }

    /**
     * Extracts a flow summary from the given flow definition
     *
     * @param flow the flow definition
     * @return the flow summary
     */
    public static Flow extract(RawJson flow) {