@Override public TableMeta deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Preconditions.checkNotNull(json); JsonObject jsonObject = json.getAsJsonObject(); String dataFormat = CommonGsonHelper.getOrDie(jsonObject, "store").getAsString(); KeyValueSet keyValueSet = context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "options"), KeyValueSet.class); return new TableMeta(dataFormat, keyValueSet); }
public static <T extends GsonObject> T fromJson(String json, Class<T> clazz) { return getInstance().fromJson(json, clazz); }
public String toJson() { return CommonGsonHelper.toJson(this, KeyValueSet.class); } }
public static Gson getPrettyInstance() { if (gsonPretty == null) { GsonBuilder prettyBuilder = new GsonBuilder() .setPrettyPrinting() .excludeFieldsWithoutExposeAnnotation(); GsonHelper.registerAdapters(prettyBuilder, registerAdapters()); gsonPretty = prettyBuilder.create(); } return gsonPretty; }
public static Gson getPrettyInstance() { if (gsonPretty == null) { GsonBuilder prettyBuilder = new GsonBuilder() .setPrettyPrinting() .excludeFieldsWithoutExposeAnnotation(); GsonHelper.registerAdapters(prettyBuilder, registerAdapters()); gsonPretty = prettyBuilder.create(); } return gsonPretty; }
@Override public TableMeta deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Preconditions.checkNotNull(json); JsonObject jsonObject = json.getAsJsonObject(); String dataFormat = CommonGsonHelper.getOrDie(jsonObject, "store").getAsString(); KeyValueSet keyValueSet = context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "options"), KeyValueSet.class); return new TableMeta(dataFormat, keyValueSet); }
public static Gson getInstance() { if (gson == null ) { GsonHelper helper = new GsonHelper(registerAdapters()); gson = helper.getGson(); } return gson; }
public String toJson() { return CommonGsonHelper.toJson(this, KeyValueSet.class); } }
public static String toJson(GsonObject object, Class<? extends GsonObject> clazz) { return getInstance().toJson(object, clazz); }
@Override public Function deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String className = CommonGsonHelper.getOrDie(jsonObject, "class").getAsJsonPrimitive().getAsString(); Class clazz; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new JsonParseException(e); } return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), clazz); } }
public static Gson getInstance() { if (gson == null ) { GsonHelper helper = new GsonHelper(registerAdapters()); gson = helper.getGson(); } return gson; }
@Override public String toJson() { return CommonGsonHelper.toJson(this, Datum.class); }
public static <T extends GsonObject> T fromJson(String json, Class<T> clazz) { return getInstance().fromJson(json, clazz); }
@Override public Function deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String className = CommonGsonHelper.getOrDie(jsonObject, "class").getAsJsonPrimitive().getAsString(); Class clazz; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new JsonParseException(e); } return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), clazz); } }
@Override public String toJson() { return CommonGsonHelper.toJson(this, Datum.class); }
public static String toJson(GsonObject object, Class<? extends GsonObject> clazz) { return getInstance().toJson(object, clazz); }
@Override public Schema deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); int version = CommonGsonHelper.getOrDie(jsonObject, "version").getAsJsonPrimitive().getAsInt(); if (version == 1) { return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), SchemaLegacy.class); } else { throw new TajoInternalError("Schema version 2 is not supported yet"); } } }
@Override public org.apache.tajo.type.Type deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = (JsonObject) json; return TypeStringEncoder.decode(CommonGsonHelper.getOrDie(obj, "type").getAsString()); }
@Override public EvalNode deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = EvalType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
@Override public PartitionMethodDescExpr deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); PartitionType type = PartitionType.valueOf( CommonGsonHelper.getOrDie(jsonObject, "PartitionType").getAsString()); switch (type) { case RANGE: return context.deserialize(json, RangePartition.class); case HASH: return context.deserialize(json, HashPartition.class); case LIST: return context.deserialize(json, ListPartition.class); case COLUMN: return context.deserialize(json, ColumnPartition.class); } return null; }