// Path: GerritStats/src/main/java/com/holmsted/gerrit/GerritStatParser.java
// public static class ParserContext {
//     final GerritVersion version;
// 
//     ParserContext(@Nonnull GerritVersion version) {
//         this.version = version;
//     }
// }
// 
// Path: GerritCommon/src/main/java/com/holmsted/json/JsonUtils.java
// public final class JsonUtils {
// 
//     @Nonnull
//     public static JSONObject readJsonString(String jsonString) {
//         return new JSONObject(new JSONTokener(jsonString));
//     }
// 
//     @Nonnull
//     public static List<String> readStringArray(JSONArray array) {
//         List<String> list = new ArrayList<>();
//         for (int i = 0; i < array.length(); ++i) {
//             list.add(array.getString(i));
//         }
//         return list;
//     }
// 
//     private JsonUtils() {
//     }
// }


import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.holmsted.gerrit.GerritStatParser.ParserContext;
import com.holmsted.json.JsonUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

        static PatchSet fromJson(@Nonnull JSONObject patchSetJson, @Nonnull ParserContext context) {
            Identity uploader = Identity.fromJson(patchSetJson.optJSONObject("uploader"));

            JSONObject authorJson = patchSetJson.optJSONObject("author");
            Identity author;
            if (authorJson != null) {
                author = Identity.fromJson(authorJson);
            } else {
                author = uploader;
            }

            String kindString = patchSetJson.optString("kind");
            PatchSetKind patchSetKind = PatchSetKind.REWORK;
            try {
                patchSetKind = PatchSetKind.valueOf(kindString);
            } catch (IllegalArgumentException e) {
                if (context.version.isAtLeast(2, 9)) {
                    System.err.println("Unknown patch set kind '" + kindString + "'");
                } else {
                    // the 'kind' field does not exist before Gerrit 2.9 or so.
                    patchSetKind = PatchSetKind.REWORK;
                }
            }

            long createdOnDate = patchSetJson.optLong("createdOn") * SEC_TO_MSEC;

            return new PatchSet(
                    patchSetJson.optInt("number"),
                    patchSetJson.optString("revision"),
// Path: GerritStats/src/main/java/com/holmsted/gerrit/GerritStatParser.java
// public static class ParserContext {
//     final GerritVersion version;
// 
//     ParserContext(@Nonnull GerritVersion version) {
//         this.version = version;
//     }
// }
// 
// Path: GerritCommon/src/main/java/com/holmsted/json/JsonUtils.java
// public final class JsonUtils {
// 
//     @Nonnull
//     public static JSONObject readJsonString(String jsonString) {
//         return new JSONObject(new JSONTokener(jsonString));
//     }
// 
//     @Nonnull
//     public static List<String> readStringArray(JSONArray array) {
//         List<String> list = new ArrayList<>();
//         for (int i = 0; i < array.length(); ++i) {
//             list.add(array.getString(i));
//         }
//         return list;
//     }
// 
//     private JsonUtils() {
//     }
// }


// Path: GerritStats/src/main/java/com/holmsted/gerrit/Commit.java
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.holmsted.gerrit.GerritStatParser.ParserContext;
import com.holmsted.json.JsonUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;


        static PatchSet fromJson(@Nonnull JSONObject patchSetJson, @Nonnull ParserContext context) {
            Identity uploader = Identity.fromJson(patchSetJson.optJSONObject("uploader"));

            JSONObject authorJson = patchSetJson.optJSONObject("author");
            Identity author;
            if (authorJson != null) {
                author = Identity.fromJson(authorJson);
            } else {
                author = uploader;
            }

            String kindString = patchSetJson.optString("kind");
            PatchSetKind patchSetKind = PatchSetKind.REWORK;
            try {
                patchSetKind = PatchSetKind.valueOf(kindString);
            } catch (IllegalArgumentException e) {
                if (context.version.isAtLeast(2, 9)) {
                    System.err.println("Unknown patch set kind '" + kindString + "'");
                } else {
                    // the 'kind' field does not exist before Gerrit 2.9 or so.
                    patchSetKind = PatchSetKind.REWORK;
                }
            }

            long createdOnDate = patchSetJson.optLong("createdOn") * SEC_TO_MSEC;

            return new PatchSet(
                    patchSetJson.optInt("number"),
                    patchSetJson.optString("revision"),
                    JsonUtils.readStringArray(patchSetJson.optJSONArray("parents")),