Jackson deserialization for ReconStats

This commit is contained in:
Antonin Delpeuch 2018-10-21 16:37:18 +01:00
parent 599edd374f
commit af866363ca

View File

@ -36,8 +36,7 @@ package com.google.refine.model;
import java.io.IOException;
import java.io.Writer;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.expr.ExpressionUtils;
@ -45,14 +44,6 @@ import com.google.refine.model.Recon.Judgment;
import com.google.refine.util.ParsingUtilities;
public class ReconStats {
static public ReconStats load(JSONObject obj) throws Exception {
return new ReconStats(
obj.getInt("nonBlanks"),
obj.getInt("newTopics"),
obj.getInt("matchedTopics")
);
}
@JsonProperty("nonBlanks")
final public int nonBlanks;
@JsonProperty("newTopics")
@ -60,7 +51,14 @@ public class ReconStats {
@JsonProperty("matchedTopics")
final public int matchedTopics;
public ReconStats(int nonBlanks, int newTopics, int matchedTopics) {
@JsonCreator
public ReconStats(
@JsonProperty("nonBlanks")
int nonBlanks,
@JsonProperty("newTopics")
int newTopics,
@JsonProperty("matchedTopics")
int matchedTopics) {
this.nonBlanks = nonBlanks;
this.newTopics = newTopics;
this.matchedTopics = matchedTopics;